use of com.wavefront.sdk.entities.histograms.HistogramGranularity in project java by wavefrontHQ.
the class InternalProxyWavefrontClient method sendDistribution.
@Override
public void sendDistribution(String name, List<Pair<Double, Integer>> centroids, Set<HistogramGranularity> histogramGranularities, Long timestamp, String source, Map<String, String> tags) {
final List<Double> bins = centroids.stream().map(x -> x._1).collect(Collectors.toList());
final List<Integer> counts = centroids.stream().map(x -> x._2).collect(Collectors.toList());
for (HistogramGranularity granularity : histogramGranularities) {
int duration;
switch(granularity) {
case MINUTE:
duration = 60000;
break;
case HOUR:
duration = 3600000;
break;
case DAY:
duration = 86400000;
break;
default:
throw new IllegalArgumentException("Unknown granularity: " + granularity);
}
Histogram histogram = Histogram.newBuilder().setType(HistogramType.TDIGEST).setBins(bins).setCounts(counts).setDuration(duration).build();
ReportPoint point = ReportPoint.newBuilder().setTable("unknown").setMetric(name).setValue(histogram).setTimestamp(timestamp).setHost(source).setAnnotations(tags).build();
histogramHandlerSupplier.get().report(point);
}
}
Aggregations