From c33ac107e21c1dad492384574d050aa0deb8bdfd Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 28 Feb 2018 22:40:31 +0800 Subject: [PATCH] getServiceTPSTrend: 1. Change the parameter name: Start -> startTimeBucket End -> endTimeBucket 2. Calculate callsPerSec metric. --- .../apm/collector/ui/query/ServiceQuery.java | 15 +++++++++------ .../collector/ui/service/ServiceNameService.java | 16 +++++++++------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java index 09c17cccf..39b546731 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java @@ -65,16 +65,19 @@ public class ServiceQuery implements Query { } public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Duration duration) throws ParseException { - long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); - long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); - return getServiceNameService().getServiceResponseTimeTrend(serviceId, duration.getStep(), start, end); + long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServiceNameService().getServiceResponseTimeTrend(serviceId, duration.getStep(), startTimeBucket, endTimeBucket); } public ThroughputTrend getServiceTPSTrend(int serviceId, Duration duration) 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 getServiceNameService().getServiceTPSTrend(serviceId, duration.getStep(), start, end); + long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); + long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); + + return getServiceNameService().getServiceTPSTrend(serviceId, duration.getStep(), startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket); } public SLATrend getServiceSLATrend(int serviceId, Duration duration) throws ParseException { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java index 30cb8b6b6..c7a58c362 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java @@ -66,21 +66,23 @@ public class ServiceNameService { return serviceNameServiceUIDAO.searchService(keyword, topN); } - public ThroughputTrend getServiceTPSTrend(int serviceId, Step step, long start, long end) throws ParseException { + public ThroughputTrend getServiceTPSTrend(int serviceId, Step step, long startTimeBucket, + long endTimeBucket, long startSecondTimeBucket, long endSecondTimeBucket) throws ParseException { ThroughputTrend throughputTrend = new ThroughputTrend(); - List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket); List callsTrends = serviceMetricUIDAO.getServiceTPSTrend(serviceId, step, durationPoints); - //TODO - callsTrends.forEach(calls -> throughputTrend.getTrendList().add(calls / 1000)); + ServiceName serviceName = serviceNameCacheService.get(serviceId); + int secondBetween = secondBetweenService.calculate(serviceName.getApplicationId(), startSecondTimeBucket, endSecondTimeBucket); + callsTrends.forEach(calls -> throughputTrend.getTrendList().add(calls / secondBetween)); return throughputTrend; } - public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Step step, long start, - long end) throws ParseException { + public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Step step, long startTimeBucket, + long endTimeBucket) throws ParseException { ResponseTimeTrend responseTimeTrend = new ResponseTimeTrend(); - List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket); responseTimeTrend.setTrendList(serviceMetricUIDAO.getServiceResponseTimeTrend(serviceId, step, durationPoints)); return responseTimeTrend; }