Search in sources :

Example 11 with DurationPoint

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;
}
Also used : MemoryTrend(org.apache.skywalking.apm.collector.storage.ui.server.MemoryTrend) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint) IMemoryMetricUIDAO(org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO)

Example 12 with DurationPoint

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;
}
Also used : MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) MultiGetItemResponse(org.elasticsearch.action.get.MultiGetItemResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) ElasticSearchClient(org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint)

Example 13 with DurationPoint

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;
}
Also used : MultiGetItemResponse(org.elasticsearch.action.get.MultiGetItemResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) ElasticSearchClient(org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint)

Example 14 with DurationPoint

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;
}
Also used : MultiGetItemResponse(org.elasticsearch.action.get.MultiGetItemResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint) MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) ElasticSearchClient(org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient) DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint)

Example 15 with DurationPoint

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;
}
Also used : DurationPoint(org.apache.skywalking.apm.collector.storage.utils.DurationPoint) ThroughputTrend(org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend)

Aggregations

DurationPoint (org.apache.skywalking.apm.collector.storage.utils.DurationPoint)17 ElasticSearchClient (org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient)8 MultiGetItemResponse (org.elasticsearch.action.get.MultiGetItemResponse)8 MultiGetRequestBuilder (org.elasticsearch.action.get.MultiGetRequestBuilder)8 MultiGetResponse (org.elasticsearch.action.get.MultiGetResponse)8 LinkedList (java.util.LinkedList)4 ResponseTimeTrend (org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend)2 ThroughputTrend (org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend)2 HashMap (java.util.HashMap)1 IMemoryMetricUIDAO (org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO)1 Application (org.apache.skywalking.apm.collector.storage.ui.application.Application)1 SLATrend (org.apache.skywalking.apm.collector.storage.ui.common.SLATrend)1 AlarmTrend (org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend)1 CPUTrend (org.apache.skywalking.apm.collector.storage.ui.server.CPUTrend)1 GCTrend (org.apache.skywalking.apm.collector.storage.ui.server.GCTrend)1 MemoryTrend (org.apache.skywalking.apm.collector.storage.ui.server.MemoryTrend)1