Histogram extends BaseMeter { @Override public MeterData.Builder transform() { final MeterData.Builder builder = MeterData.newBuilder(); List<MeterBucketValue> values = Arrays.stream(buckets) .map(Histogram.Bucket::transform).collect(Collectors.toList()); return builder.setHistogram(MeterHistogram.newBuilder() .setName(getName()) .addAllLabels(transformTags()) .addAllValues(values) .build()); } Histogram(MeterId meterId, List<Double> steps); void addValue(double value); @Override MeterData.Builder transform();  }
@Test public void testTransform() { final List<Label> labels = Arrays.asList(Label.newBuilder().setName("k1").setValue("v1").build()); final Histogram histogram = MeterFactory.histogram("test") .steps(Arrays.asList(2d, 5d)) .minValue(1d) .tag("k1", "v1") .build(); histogram.addValue(1); histogram.addValue(3); histogram.addValue(3); histogram.addValue(7); verifyHistogram("test", labels, Arrays.asList(1d, 2d, 5d), Arrays.asList(1L, 2L, 1L), histogram.transform()); histogram.addValue(9); verifyHistogram("test", labels, Arrays.asList(1d, 2d, 5d), Arrays.asList(1L, 2L, 2L), histogram.transform()); }