use of org.apache.skywalking.apm.collector.storage.utils.DurationPoint in project incubator-skywalking by apache.
the class ServerService method getMemoryTrend.
public MemoryTrend getMemoryTrend(int instanceId, Step step, long startTimeBucket, long endTimeBucket) throws ParseException {
MemoryTrend memoryTrend = new MemoryTrend();
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket);
IMemoryMetricUIDAO.Trend heapMemoryTrend = memoryMetricUIDAO.getHeapMemoryTrend(instanceId, step, durationPoints);
memoryTrend.setHeap(heapMemoryTrend.getMetrics());
memoryTrend.setMaxHeap(heapMemoryTrend.getMaxMetrics());
IMemoryMetricUIDAO.Trend noHeapMemoryTrend = memoryMetricUIDAO.getNoHeapMemoryTrend(instanceId, step, durationPoints);
memoryTrend.setNoheap(noHeapMemoryTrend.getMetrics());
memoryTrend.setMaxNoheap(noHeapMemoryTrend.getMaxMetrics());
return memoryTrend;
}
use of org.apache.skywalking.apm.collector.storage.utils.DurationPoint in project incubator-skywalking by apache.
the class MemoryMetricEsUIDAO method getMemoryTrend.
private Trend getMemoryTrend(int instanceId, Step step, List<DurationPoint> durationPoints, boolean isHeap) {
String tableName = TimePyramidTableNameBuilder.build(step, MemoryMetricTable.TABLE);
MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(durationPoints, new ElasticSearchClient.MultiGetRowHandler<DurationPoint>() {
@Override
public void accept(DurationPoint durationPoint) {
String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + BooleanUtils.booleanToValue(isHeap);
add(tableName, MemoryMetricTable.TABLE_TYPE, id);
}
});
Trend trend = new Trend();
MultiGetResponse multiGetResponse = prepareMultiGet.get();
for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
if (response.getResponse().isExists()) {
long max = ((Number) response.getResponse().getSource().get(MemoryMetricTable.COLUMN_MAX)).longValue();
long used = ((Number) response.getResponse().getSource().get(MemoryMetricTable.COLUMN_USED)).longValue();
long times = ((Number) response.getResponse().getSource().get(MemoryMetricTable.COLUMN_TIMES)).longValue();
trend.getMetrics().add((int) (used / times));
if (max < 0) {
trend.getMaxMetrics().add((int) (used / times));
} else {
trend.getMaxMetrics().add((int) (max / times));
}
} else {
trend.getMetrics().add(0);
trend.getMaxMetrics().add(0);
}
}
return trend;
}
use of org.apache.skywalking.apm.collector.storage.utils.DurationPoint in project incubator-skywalking by apache.
the class ServiceMetricEsUIDAO method getServiceResponseTimeTrend.
@Override
public List<Integer> getServiceResponseTimeTrend(int serviceId, Step step, List<DurationPoint> durationPoints) {
String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE);
MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(durationPoints, new ElasticSearchClient.MultiGetRowHandler<DurationPoint>() {
@Override
public void accept(DurationPoint durationPoint) {
String id = durationPoint.getPoint() + Const.ID_SPLIT + serviceId + Const.ID_SPLIT + MetricSource.Callee.getValue();
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 durationSum = ((Number) response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue();
trends.add((int) (durationSum / calls));
} else {
trends.add(0);
}
}
return trends;
}
use of org.apache.skywalking.apm.collector.storage.utils.DurationPoint in project incubator-skywalking by apache.
the class ServiceMetricEsUIDAO method getServiceTPSTrend.
@Override
public List<Integer> getServiceTPSTrend(int serviceId, Step step, List<DurationPoint> durationPoints) {
String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE);
MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(durationPoints, new ElasticSearchClient.MultiGetRowHandler<DurationPoint>() {
@Override
public void accept(DurationPoint durationPoint) {
String id = durationPoint.getPoint() + Const.ID_SPLIT + serviceId + Const.ID_SPLIT + MetricSource.Callee.getValue();
add(tableName, ServiceMetricTable.TABLE_TYPE, id);
}
});
List<Integer> trends = new LinkedList<>();
MultiGetResponse multiGetResponse = prepareMultiGet.get();
int index = 0;
for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
if (response.getResponse().isExists()) {
long calls = ((Number) response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue();
long secondBetween = durationPoints.get(index).getSecondsBetween();
trends.add((int) (calls / secondBetween));
} else {
trends.add(0);
}
index++;
}
return trends;
}
use of org.apache.skywalking.apm.collector.storage.utils.DurationPoint in project incubator-skywalking by apache.
the class ServiceNameService method getServiceTPSTrend.
public ThroughputTrend getServiceTPSTrend(int serviceId, Step step, long startTimeBucket, long endTimeBucket) throws ParseException {
ThroughputTrend throughputTrend = new ThroughputTrend();
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket);
List<Integer> throughputTrends = serviceMetricUIDAO.getServiceTPSTrend(serviceId, step, durationPoints);
throughputTrend.setTrendList(throughputTrends);
return throughputTrend;
}
Aggregations