Provide the getServiceTPSTrend query.
This commit is contained in:
parent
4419bca46f
commit
0c9686e437
|
|
@ -33,6 +33,8 @@ import org.apache.skywalking.apm.collector.storage.utils.DurationPoint;
|
|||
public interface IServiceMetricUIDAO extends DAO {
|
||||
List<Integer> getServiceResponseTimeTrend(int serviceId, Step step, List<DurationPoint> durationPoints);
|
||||
|
||||
List<Integer> getServiceTPSTrend(int serviceId, Step step, List<DurationPoint> durationPoints);
|
||||
|
||||
List<Integer> getServiceSLATrend(int serviceId, Step step, List<DurationPoint> durationPoints);
|
||||
|
||||
List<Node> getServicesMetric(Step step, long startTime, long endTime,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.storage.ui.common;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -26,6 +27,10 @@ import java.util.List;
|
|||
public class ThroughputTrend {
|
||||
private List<Integer> trendList;
|
||||
|
||||
public ThroughputTrend() {
|
||||
this.trendList = new LinkedList<>();
|
||||
}
|
||||
|
||||
public List<Integer> getTrendList() {
|
||||
return trendList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,6 +88,29 @@ public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO {
|
|||
return trends;
|
||||
}
|
||||
|
||||
@Override public List<Integer> getServiceTPSTrend(int serviceId, Step step, List<DurationPoint> durationPoints) {
|
||||
MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet();
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE);
|
||||
|
||||
durationPoints.forEach(durationPoint -> {
|
||||
String id = durationPoint.getPoint() + Const.ID_SPLIT + serviceId + Const.ID_SPLIT + MetricSource.Callee.getValue();
|
||||
prepareMultiGet.add(tableName, ServiceMetricTable.TABLE_TYPE, id);
|
||||
});
|
||||
|
||||
List<Integer> trends = new LinkedList<>();
|
||||
MultiGetResponse multiGetResponse = prepareMultiGet.get();
|
||||
for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
|
||||
if (response.getResponse().isExists()) {
|
||||
long calls = ((Number)response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue();
|
||||
long errorCalls = ((Number)response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue();
|
||||
trends.add((int)(calls - errorCalls));
|
||||
} else {
|
||||
trends.add(0);
|
||||
}
|
||||
}
|
||||
return trends;
|
||||
}
|
||||
|
||||
@Override public List<Integer> getServiceSLATrend(int serviceId, Step step, List<DurationPoint> durationPoints) {
|
||||
MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet();
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE);
|
||||
|
|
|
|||
|
|
@ -80,6 +80,10 @@ public class ServiceMetricH2UIDAO extends H2DAO implements IServiceMetricUIDAO {
|
|||
return trends;
|
||||
}
|
||||
|
||||
@Override public List<Integer> getServiceTPSTrend(int serviceId, Step step, List<DurationPoint> durationPoints) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public List<Integer> getServiceSLATrend(int serviceId, Step step, List<DurationPoint> durationPoints) {
|
||||
String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE);
|
||||
|
||||
|
|
|
|||
|
|
@ -70,8 +70,11 @@ public class ServiceQuery implements Query {
|
|||
return getServiceNameService().getServiceResponseTimeTrend(serviceId, duration.getStep(), start, end);
|
||||
}
|
||||
|
||||
public ThroughputTrend getServiceTPSTrend(int serviceId, Duration duration) {
|
||||
return null;
|
||||
public ThroughputTrend getServiceTPSTrend(int serviceId, Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
|
||||
|
||||
return getServiceNameService().getServiceTPSTrend(serviceId, duration.getStep(), start, end);
|
||||
}
|
||||
|
||||
public SLATrend getServiceSLATrend(int serviceId, Duration duration) throws ParseException {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.apache.skywalking.apm.collector.storage.table.MetricSource;
|
|||
import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.SLATrend;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric;
|
||||
import org.apache.skywalking.apm.collector.storage.utils.DurationPoint;
|
||||
|
|
@ -58,6 +59,17 @@ public class ServiceNameService {
|
|||
return serviceNameServiceUIDAO.searchService(keyword, topN);
|
||||
}
|
||||
|
||||
public ThroughputTrend getServiceTPSTrend(int serviceId, Step step, long start, long end) throws ParseException {
|
||||
ThroughputTrend throughputTrend = new ThroughputTrend();
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end);
|
||||
List<Integer> callsTrends = serviceMetricUIDAO.getServiceTPSTrend(serviceId, step, durationPoints);
|
||||
|
||||
//TODO
|
||||
callsTrends.forEach(calls -> throughputTrend.getTrendList().add(calls / 1000));
|
||||
|
||||
return throughputTrend;
|
||||
}
|
||||
|
||||
public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Step step, long start,
|
||||
long end) throws ParseException {
|
||||
ResponseTimeTrend responseTimeTrend = new ResponseTimeTrend();
|
||||
|
|
|
|||
Loading…
Reference in New Issue