Search in sources :

Example 1 with UriStatHistogramBucket

use of com.navercorp.pinpoint.common.trace.UriStatHistogramBucket in project pinpoint by naver.

the class SampledUriStatHistogramBo method getUriStatHistogramValue.

public int[] getUriStatHistogramValue() {
    int[] newArrayValue = new int[UriStatHistogramBucket.getBucketSize()];
    for (Map.Entry<UriStatHistogramBucket, Integer> entry : uriStatHistogramCountMap.entrySet()) {
        int index = entry.getKey().getIndex();
        newArrayValue[index] = entry.getValue();
    }
    return newArrayValue;
}
Also used : Map(java.util.Map) UriStatHistogramBucket(com.navercorp.pinpoint.common.trace.UriStatHistogramBucket) AgentStatPoint(com.navercorp.pinpoint.web.vo.stat.chart.agent.AgentStatPoint)

Example 2 with UriStatHistogramBucket

use of com.navercorp.pinpoint.common.trace.UriStatHistogramBucket in project pinpoint by naver.

the class TestAgentStatFactory method createHistogram.

private static UriStatHistogram createHistogram(int[] elapsedTimes, int sample) {
    UriStatHistogram uriStatHistogram = new UriStatHistogram();
    int count = 0;
    long totalElapsed = 0;
    long max = 0;
    int histogramSize = UriStatHistogramBucket.values().length;
    int[] histogramBucket = new int[histogramSize];
    for (int i = 0; i < elapsedTimes.length; i++) {
        if (RandomUtils.nextInt(0, sample) != 0) {
            continue;
        }
        long elapsedTime = elapsedTimes[i];
        totalElapsed += elapsedTime;
        max = Math.max(max, elapsedTime);
        count++;
        UriStatHistogramBucket value = UriStatHistogramBucket.getValue(elapsedTime);
        histogramBucket[value.getIndex()] += 1;
    }
    if (count == 0) {
        return null;
    }
    uriStatHistogram.setCount(count);
    uriStatHistogram.setAvg(totalElapsed / count);
    uriStatHistogram.setMax(max);
    uriStatHistogram.setTimestampHistogram(histogramBucket);
    return uriStatHistogram;
}
Also used : UriStatHistogramBucket(com.navercorp.pinpoint.common.trace.UriStatHistogramBucket)

Example 3 with UriStatHistogramBucket

use of com.navercorp.pinpoint.common.trace.UriStatHistogramBucket in project pinpoint by naver.

the class UriStatHistogram method add.

public void add(long elapsed) {
    count++;
    total += elapsed;
    this.max = Math.max(max, elapsed);
    UriStatHistogramBucket uriStatHistogramBucket = UriStatHistogramBucket.getValue(elapsed);
    timestampHistogram[uriStatHistogramBucket.getIndex()] = ++timestampHistogram[uriStatHistogramBucket.getIndex()];
}
Also used : UriStatHistogramBucket(com.navercorp.pinpoint.common.trace.UriStatHistogramBucket)

Example 4 with UriStatHistogramBucket

use of com.navercorp.pinpoint.common.trace.UriStatHistogramBucket in project pinpoint by naver.

the class AgentUriStatSampler method create.

private SampledUriStatHistogramBo create(long timestamp, List<UriStatHistogram> uriStatHistogramList) {
    if (CollectionUtils.isEmpty(uriStatHistogramList)) {
        return createEmptySampledUriStatHistogramBo(timestamp);
    }
    final List<Integer> countList = uriStatHistogramList.stream().map(UriStatHistogram::getCount).collect(Collectors.toList());
    final AgentStatPoint<Integer> countPoint = AGENT_STAT_POINT_FACTORY.createIntPoint(timestamp, countList);
    final List<Long> maxElapsedTimeList = uriStatHistogramList.stream().map(UriStatHistogram::getMax).collect(Collectors.toList());
    final AgentStatPoint<Long> maxElapsedTimePoint = AGENT_STAT_POINT_FACTORY.createLongPoint(timestamp, maxElapsedTimeList);
    final List<Double> avgElapsedTimeList = uriStatHistogramList.stream().map(UriStatHistogram::getAvg).collect(Collectors.toList());
    final AgentStatPoint<Double> avgElapsedTimePoint = AGENT_STAT_POINT_FACTORY.createDoublePoint(timestamp, avgElapsedTimeList, 3);
    final Map<UriStatHistogramBucket, Integer> uriStatHistogramCountMap = createHistogramBucketCountMap(uriStatHistogramList);
    long totalElapsedTime = 0;
    for (int i = 0; i < countList.size(); i++) {
        totalElapsedTime += (countList.get(i) * avgElapsedTimeList.get(i));
    }
    SampledUriStatHistogramBo sampledUriStatHistogramBo = new SampledUriStatHistogramBo(countPoint, maxElapsedTimePoint, avgElapsedTimePoint, uriStatHistogramCountMap, totalElapsedTime);
    return sampledUriStatHistogramBo;
}
Also used : SampledUriStatHistogramBo(com.navercorp.pinpoint.web.vo.stat.SampledUriStatHistogramBo) UriStatHistogramBucket(com.navercorp.pinpoint.common.trace.UriStatHistogramBucket) AgentStatPoint(com.navercorp.pinpoint.web.vo.stat.chart.agent.AgentStatPoint)

Example 5 with UriStatHistogramBucket

use of com.navercorp.pinpoint.common.trace.UriStatHistogramBucket in project pinpoint by naver.

the class AgentUriStatSamplerTest method createUriStatHistogram.

private UriStatHistogram createUriStatHistogram(int count) {
    long totalElapsed = 0;
    long max = 0;
    int[] bucketValues = new int[UriStatHistogramBucket.getBucketSize()];
    for (int i = 0; i < count; i++) {
        int elapsed = ThreadLocalRandom.current().nextInt(10000);
        totalElapsed += elapsed;
        max = Math.max(max, elapsed);
        UriStatHistogramBucket bucket = UriStatHistogramBucket.getValue(elapsed);
        bucketValues[bucket.getIndex()] += 1;
    }
    UriStatHistogram uriStatHistogram = new UriStatHistogram();
    uriStatHistogram.setCount(count);
    uriStatHistogram.setAvg(totalElapsed / count);
    uriStatHistogram.setMax(max);
    uriStatHistogram.setTimestampHistogram(bucketValues);
    return uriStatHistogram;
}
Also used : UriStatHistogramBucket(com.navercorp.pinpoint.common.trace.UriStatHistogramBucket) AgentStatPoint(com.navercorp.pinpoint.web.vo.stat.chart.agent.AgentStatPoint) UriStatHistogram(com.navercorp.pinpoint.common.server.bo.stat.UriStatHistogram)

Aggregations

UriStatHistogramBucket (com.navercorp.pinpoint.common.trace.UriStatHistogramBucket)8 AgentStatPoint (com.navercorp.pinpoint.web.vo.stat.chart.agent.AgentStatPoint)4 UriStatHistogram (com.navercorp.pinpoint.common.server.bo.stat.UriStatHistogram)2 SampledUriStatHistogramBo (com.navercorp.pinpoint.web.vo.stat.SampledUriStatHistogramBo)1 EnumMap (java.util.EnumMap)1 Map (java.util.Map)1