Calculate callsPerSec metric.
This commit is contained in:
parent
e138b8d5fc
commit
9b24f52750
|
|
@ -87,10 +87,13 @@ public class ApplicationQuery implements Query {
|
|||
|
||||
public List<ServiceMetric> getSlowService(int applicationId, Duration duration,
|
||||
Integer topN) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
|
||||
return getApplicationService().getSlowService(applicationId, duration.getStep(), start, end, topN);
|
||||
long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
|
||||
long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
|
||||
|
||||
return getApplicationService().getSlowService(applicationId, duration.getStep(), startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket, topN);
|
||||
}
|
||||
|
||||
public List<AppServerInfo> getServerThroughput(int applicationId, Duration duration,
|
||||
|
|
|
|||
|
|
@ -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.table.MetricSource;
|
||||
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.common.Step;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationTPS;
|
||||
|
|
@ -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.service.ServiceMetric;
|
||||
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ApplicationService.class);
|
||||
|
||||
private final IInstanceUIDAO instanceDAO;
|
||||
private final IServiceMetricUIDAO serviceMetricUIDAO;
|
||||
private final IApplicationMetricUIDAO applicationMetricUIDAO;
|
||||
private final INetworkAddressUIDAO networkAddressUIDAO;
|
||||
private final ApplicationCacheService applicationCacheService;
|
||||
private final ServiceNameCacheService serviceNameCacheService;
|
||||
private final SecondBetweenService secondBetweenService;
|
||||
|
||||
public ApplicationService(ModuleManager moduleManager) {
|
||||
this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class);
|
||||
|
|
@ -59,6 +65,7 @@ public class ApplicationService {
|
|||
this.networkAddressUIDAO = moduleManager.find(StorageModule.NAME).getService(INetworkAddressUIDAO.class);
|
||||
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
|
||||
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
|
||||
this.secondBetweenService = new SecondBetweenService(moduleManager);
|
||||
}
|
||||
|
||||
public List<Application> getApplications(long startSecondTimeBucket, long endSecondTimeBucket,
|
||||
|
|
@ -78,13 +85,18 @@ public class ApplicationService {
|
|||
return applications;
|
||||
}
|
||||
|
||||
public List<ServiceMetric> getSlowService(int applicationId, Step step, long start, long end,
|
||||
Integer top) throws ParseException {
|
||||
List<ServiceMetric> slowServices = serviceMetricUIDAO.getSlowService(applicationId, step, start, end, top, MetricSource.Callee);
|
||||
public List<ServiceMetric> getSlowService(int applicationId, Step step, long startTimeBucket, long endTimeBucket,
|
||||
long startSecondTimeBucket, long endSecondTimeBucket, Integer topN) throws ParseException {
|
||||
List<ServiceMetric> slowServices = serviceMetricUIDAO.getSlowService(applicationId, step, startTimeBucket, endTimeBucket, topN, MetricSource.Callee);
|
||||
slowServices.forEach(slowService -> {
|
||||
slowService.setName(serviceNameCacheService.get(slowService.getId()).getServiceName());
|
||||
//TODO
|
||||
slowService.setCallsPerSec(1);
|
||||
ServiceName serviceName = serviceNameCacheService.get(slowService.getId());
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue