Search in sources :

Example 1 with HistogramGranularity

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);
    }
}
Also used : WavefrontSender(com.wavefront.sdk.common.WavefrontSender) Set(java.util.Set) IOException(java.io.IOException) UUID(java.util.UUID) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) ReportableEntityType(com.wavefront.data.ReportableEntityType) List(java.util.List) Pair(com.wavefront.sdk.common.Pair) Map(java.util.Map) ReportPoint(wavefront.report.ReportPoint) Utils.lazySupplier(com.wavefront.common.Utils.lazySupplier) Clock(com.wavefront.common.Clock) HistogramGranularity(com.wavefront.sdk.entities.histograms.HistogramGranularity) SpanLog(com.wavefront.sdk.entities.tracing.SpanLog) Histogram(wavefront.report.Histogram) HistogramType(wavefront.report.HistogramType) Nullable(javax.annotation.Nullable) Histogram(wavefront.report.Histogram) HistogramGranularity(com.wavefront.sdk.entities.histograms.HistogramGranularity) ReportPoint(wavefront.report.ReportPoint) ReportPoint(wavefront.report.ReportPoint)

Aggregations

Clock (com.wavefront.common.Clock)1 Utils.lazySupplier (com.wavefront.common.Utils.lazySupplier)1 ReportableEntityType (com.wavefront.data.ReportableEntityType)1 Pair (com.wavefront.sdk.common.Pair)1 WavefrontSender (com.wavefront.sdk.common.WavefrontSender)1 HistogramGranularity (com.wavefront.sdk.entities.histograms.HistogramGranularity)1 SpanLog (com.wavefront.sdk.entities.tracing.SpanLog)1 IOException (java.io.IOException)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 UUID (java.util.UUID)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 Histogram (wavefront.report.Histogram)1 HistogramType (wavefront.report.HistogramType)1 ReportPoint (wavefront.report.ReportPoint)1