use of com.navercorp.pinpoint.common.server.bo.stat.UriStatHistogram in project pinpoint by naver.
the class GrpcAgentUriStatMapper method createEachUriStatBo.
private EachUriStatBo createEachUriStatBo(PEachUriStat pEachUriStat) {
EachUriStatBo eachUriStatBo = new EachUriStatBo();
final String uri = pEachUriStat.getUri();
eachUriStatBo.setUri(uri);
PUriHistogram pTotalHistogram = pEachUriStat.getTotalHistogram();
final UriStatHistogram totalHistogram = convertUriStatHistogram(pTotalHistogram);
eachUriStatBo.setTotalHistogram(totalHistogram);
PUriHistogram pFailedHistogram = pEachUriStat.getFailedHistogram();
final UriStatHistogram failedHistogram = convertUriStatHistogram(pFailedHistogram);
eachUriStatBo.setFailedHistogram(failedHistogram);
return eachUriStatBo;
}
use of com.navercorp.pinpoint.common.server.bo.stat.UriStatHistogram in project pinpoint by naver.
the class AgentUriStatSampler method sampleDataPoints.
@Override
public SampledEachUriStatBo sampleDataPoints(int index, long timestamp, List<EachUriStatBo> eachUriStatBoList, EachUriStatBo previousDataPoint) {
if (CollectionUtils.isEmpty(eachUriStatBoList)) {
return null;
}
final String uri = getUri(eachUriStatBoList);
List<UriStatHistogram> totalUriStatHistogramList = eachUriStatBoList.stream().map(EachUriStatBo::getTotalHistogram).filter(Objects::nonNull).collect(Collectors.toList());
SampledUriStatHistogramBo sampledTotalUriStatHistogramBo = create(timestamp, totalUriStatHistogramList);
List<UriStatHistogram> failedUriStatHistogramList = eachUriStatBoList.stream().map(EachUriStatBo::getFailedHistogram).filter(Objects::nonNull).collect(Collectors.toList());
SampledUriStatHistogramBo failedSampledUriStatHistogramBo = create(timestamp, failedUriStatHistogramList);
SampledEachUriStatBo sampledEachUriStatBo = new SampledEachUriStatBo(uri, sampledTotalUriStatHistogramBo, failedSampledUriStatHistogramBo);
return sampledEachUriStatBo;
}
use of com.navercorp.pinpoint.common.server.bo.stat.UriStatHistogram 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;
}
use of com.navercorp.pinpoint.common.server.bo.stat.UriStatHistogram in project pinpoint by naver.
the class GrpcAgentUriStatMapper method convertUriStatHistogram.
private UriStatHistogram convertUriStatHistogram(PUriHistogram pUriHistogram) {
int count = pUriHistogram.getCount();
if (count == 0) {
return null;
}
double avg = pUriHistogram.getAvg();
long max = pUriHistogram.getMax();
int histogramCount = pUriHistogram.getHistogramCount();
List<Integer> histogramList = pUriHistogram.getHistogramList();
int[] histogram = new int[histogramCount];
for (int i = 0; i < histogramCount; i++) {
histogram[i] = histogramList.get(i);
}
UriStatHistogram uriStatHistogram = new UriStatHistogram();
uriStatHistogram.setCount(count);
uriStatHistogram.setAvg(avg);
uriStatHistogram.setMax(max);
uriStatHistogram.setTimestampHistogram(histogram);
return uriStatHistogram;
}
use of com.navercorp.pinpoint.common.server.bo.stat.UriStatHistogram in project pinpoint by naver.
the class AgentUriStatSampler method createHistogramBucketCountMap.
private Map<UriStatHistogramBucket, Integer> createHistogramBucketCountMap(List<UriStatHistogram> uriStatHistogramList) {
int[] mergedHistogramValue = new int[UriStatHistogramBucket.getBucketSize()];
for (UriStatHistogram uriStatHistogram : uriStatHistogramList) {
int[] timestampHistogram = uriStatHistogram.getTimestampHistogram();
for (int i = 0; i < mergedHistogramValue.length; i++) {
mergedHistogramValue[i] += timestampHistogram[i];
}
}
Map<UriStatHistogramBucket, Integer> uriStatHistogramBucketCountMap = new EnumMap<>(UriStatHistogramBucket.class);
for (UriStatHistogramBucket value : BUCKETS) {
int eachBucketTotalCount = mergedHistogramValue[value.getIndex()];
uriStatHistogramBucketCountMap.put(value, eachBucketTotalCount);
}
return uriStatHistogramBucketCountMap;
}
Aggregations