提交 c33ac107 编写于 作者: P peng-yongsheng

getServiceTPSTrend:

1. Change the parameter name:
Start -> startTimeBucket
End -> endTimeBucket
2. Calculate callsPerSec metric.
上级 96b5b203
......@@ -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());
long startSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
long endSecondTimeBucket = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
return getServiceNameService().getServiceTPSTrend(serviceId, duration.getStep(), start, end);
return getServiceNameService().getServiceTPSTrend(serviceId, duration.getStep(), startTimeBucket, endTimeBucket, startSecondTimeBucket, endSecondTimeBucket);
}
public SLATrend getServiceSLATrend(int serviceId, Duration duration) throws ParseException {
......
......@@ -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<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end);
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket);
List<Integer> 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<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end);
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket);
responseTimeTrend.setTrendList(serviceMetricUIDAO.getServiceResponseTimeTrend(serviceId, step, durationPoints));
return responseTimeTrend;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册