未验证 提交 71eb594e 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

Merge pull request #846 from peng-yongsheng/feature/getSlowService

"getSlowService" Calculate callsPerSec metric.
...@@ -87,10 +87,13 @@ public class ApplicationQuery implements Query { ...@@ -87,10 +87,13 @@ public class ApplicationQuery implements Query {
public List<ServiceMetric> getSlowService(int applicationId, Duration duration, public List<ServiceMetric> getSlowService(int applicationId, Duration duration,
Integer topN) throws ParseException { Integer topN) throws ParseException {
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
return getApplicationService().getSlowService(applicationId, duration.getStep(), start, end, topN); return getApplicationService().getSlowService(applicationId, duration.getStep(), startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket, topN);
} }
public List<AppServerInfo> getServerThroughput(int applicationId, Duration duration, public List<AppServerInfo> getServerThroughput(int applicationId, Duration duration,
......
...@@ -32,6 +32,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; ...@@ -32,6 +32,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO;
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO;
import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.table.register.ServerTypeDefine; import org.apache.skywalking.apm.collector.storage.table.register.ServerTypeDefine;
import org.apache.skywalking.apm.collector.storage.table.register.ServiceName;
import org.apache.skywalking.apm.collector.storage.ui.application.Application; import org.apache.skywalking.apm.collector.storage.ui.application.Application;
import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.ui.common.Step;
import org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationTPS; import org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationTPS;
...@@ -39,18 +40,23 @@ import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalApp; ...@@ -39,18 +40,23 @@ import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalApp;
import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalAppBrief; import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalAppBrief;
import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric; import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric;
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @author peng-yongsheng * @author peng-yongsheng
*/ */
public class ApplicationService { public class ApplicationService {
private final Logger logger = LoggerFactory.getLogger(ApplicationService.class);
private final IInstanceUIDAO instanceDAO; private final IInstanceUIDAO instanceDAO;
private final IServiceMetricUIDAO serviceMetricUIDAO; private final IServiceMetricUIDAO serviceMetricUIDAO;
private final IApplicationMetricUIDAO applicationMetricUIDAO; private final IApplicationMetricUIDAO applicationMetricUIDAO;
private final INetworkAddressUIDAO networkAddressUIDAO; private final INetworkAddressUIDAO networkAddressUIDAO;
private final ApplicationCacheService applicationCacheService; private final ApplicationCacheService applicationCacheService;
private final ServiceNameCacheService serviceNameCacheService; private final ServiceNameCacheService serviceNameCacheService;
private final SecondBetweenService secondBetweenService;
public ApplicationService(ModuleManager moduleManager) { public ApplicationService(ModuleManager moduleManager) {
this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class); this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class);
...@@ -59,6 +65,7 @@ public class ApplicationService { ...@@ -59,6 +65,7 @@ public class ApplicationService {
this.networkAddressUIDAO = moduleManager.find(StorageModule.NAME).getService(INetworkAddressUIDAO.class); this.networkAddressUIDAO = moduleManager.find(StorageModule.NAME).getService(INetworkAddressUIDAO.class);
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class); this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
this.secondBetweenService = new SecondBetweenService(moduleManager);
} }
public List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket, public List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket,
...@@ -78,13 +85,18 @@ public class ApplicationService { ...@@ -78,13 +85,18 @@ public class ApplicationService {
return applications; return applications;
} }
public List<ServiceMetric> getSlowService(int applicationId, Step step, long start, long end, public List<ServiceMetric> getSlowService(int applicationId, Step step, long startTimeBucket, long endTimeBucket,
Integer top) throws ParseException { long startSecondTimeBucket, long endSecondTimeBucket, Integer topN) throws ParseException {
List<ServiceMetric> slowServices = serviceMetricUIDAO.getSlowService(applicationId, step, start, end, top, MetricSource.Callee); List<ServiceMetric> slowServices = serviceMetricUIDAO.getSlowService(applicationId, step, startTimeBucket, endTimeBucket, topN, MetricSource.Callee);
slowServices.forEach(slowService -> { slowServices.forEach(slowService -> {
slowService.setName(serviceNameCacheService.get(slowService.getId()).getServiceName()); ServiceName serviceName = serviceNameCacheService.get(slowService.getId());
//TODO
slowService.setCallsPerSec(1); try {
slowService.setCallsPerSec((int)(slowService.getCalls() / secondBetweenService.calculate(serviceName.getApplicationId(), startSecondTimeBucket, endSecondTimeBucket)));
} catch (ParseException e) {
logger.error(e.getMessage(), e);
}
slowService.setName(serviceName.getServiceName());
}); });
return slowServices; return slowServices;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册