diff --git a/micrometer-registry-signalfx/src/main/java/io/micrometer/signalfx/SignalfxDistributionSummary.java b/micrometer-registry-signalfx/src/main/java/io/micrometer/signalfx/SignalfxDistributionSummary.java index 37b981c9..e66d3121 100644 --- a/micrometer-registry-signalfx/src/main/java/io/micrometer/signalfx/SignalfxDistributionSummary.java +++ b/micrometer-registry-signalfx/src/main/java/io/micrometer/signalfx/SignalfxDistributionSummary.java @@ -69,8 +69,7 @@ final class SignalfxDistributionSummary extends AbstractDistributionSummary { super(id, clock, CumulativeHistogramConfigUtil.updateConfig(distributionStatisticConfig), scale, false); this.countTotal = new StepTuple2<>(clock, stepMillis, 0L, 0.0, count::sumThenReset, total::sumThenReset); this.max = new TimeWindowMax(clock, distributionStatisticConfig); - if (!distributionStatisticConfig.isPublishingPercentiles() - && distributionStatisticConfig.isPublishingHistogram() && isDelta) { + if (distributionStatisticConfig.isPublishingHistogram() && isDelta) { deltaHistogramCounts = new DeltaHistogramCounts(); } else { @@ -106,12 +105,10 @@ public HistogramSnapshot takeSnapshot() { if (deltaHistogramCounts == null) { return currentSnapshot; } - return new HistogramSnapshot(currentSnapshot.count(), // Already delta in sfx - // implementation + return new HistogramSnapshot(currentSnapshot.count(), // Already delta in sfx implementation currentSnapshot.total(), // Already delta in sfx implementation - currentSnapshot.max(), // Max cannot be calculated as delta, keep the - // current. - null, // No percentile values + currentSnapshot.max(), // Max cannot be calculated as delta, keep the current. + currentSnapshot.percentileValues(), // No changes to the percentile values. deltaHistogramCounts.calculate(currentSnapshot.histogramCounts()), currentSnapshot::outputSummary); } } diff --git a/micrometer-registry-signalfx/src/main/java/io/micrometer/signalfx/SignalfxTimer.java b/micrometer-registry-signalfx/src/main/java/io/micrometer/signalfx/SignalfxTimer.java index ed52d007..3a164e95 100644 --- a/micrometer-registry-signalfx/src/main/java/io/micrometer/signalfx/SignalfxTimer.java +++ b/micrometer-registry-signalfx/src/main/java/io/micrometer/signalfx/SignalfxTimer.java @@ -72,8 +72,7 @@ final class SignalfxTimer extends AbstractTimer { baseTimeUnit, false); countTotal = new StepTuple2<>(clock, stepMillis, 0L, 0L, count::sumThenReset, total::sumThenReset); max = new TimeWindowMax(clock, distributionStatisticConfig); - if (!distributionStatisticConfig.isPublishingPercentiles() - && distributionStatisticConfig.isPublishingHistogram() && isDelta) { + if (distributionStatisticConfig.isPublishingHistogram() && isDelta) { deltaHistogramCounts = new DeltaHistogramCounts(); } else { @@ -110,12 +109,10 @@ public HistogramSnapshot takeSnapshot() { if (deltaHistogramCounts == null) { return currentSnapshot; } - return new HistogramSnapshot(currentSnapshot.count(), // Already delta in sfx - // implementation + return new HistogramSnapshot(currentSnapshot.count(), // Already delta in sfx implementation currentSnapshot.total(), // Already delta in sfx implementation - currentSnapshot.max(), // Max cannot be calculated as delta, keep the - // current. - null, // No percentile values + currentSnapshot.max(), // Max cannot be calculated as delta, keep the current. + currentSnapshot.percentileValues(), // No changes to the percentile values. deltaHistogramCounts.calculate(currentSnapshot.histogramCounts()), currentSnapshot::outputSummary); } } diff --git a/micrometer-registry-signalfx/src/test/java/io/micrometer/signalfx/SignalFxMeterRegistryTest.java b/micrometer-registry-signalfx/src/test/java/io/micrometer/signalfx/SignalFxMeterRegistryTest.java index 09e5b742..e2349921 100644 --- a/micrometer-registry-signalfx/src/test/java/io/micrometer/signalfx/SignalFxMeterRegistryTest.java +++ b/micrometer-registry-signalfx/src/test/java/io/micrometer/signalfx/SignalFxMeterRegistryTest.java @@ -189,11 +189,12 @@ void shouldConfigureCumulativeHistogram_DistributionSummary() { } @ParameterizedTest - @ArgumentsSource(TimerBuckets.class) - void shouldExportCumulativeHistogramData_Timer(Duration[] buckets) { + @ArgumentsSource(TimerArguments.class) + void shouldExportCumulativeHistogramData_Timer(Duration[] buckets, double[] percentiles) { MockClock mockClock = new MockClock(); SignalFxMeterRegistry registry = new SignalFxMeterRegistry(cumulativeHistogramConfig, mockClock); - Timer timer = Timer.builder("my.timer").serviceLevelObjectives(buckets).register(registry); + Timer timer = Timer.builder("my.timer").publishPercentiles(percentiles).serviceLevelObjectives(buckets) + .register(registry); timer.record(5, TimeUnit.MILLISECONDS); timer.record(20, TimeUnit.MILLISECONDS); @@ -204,15 +205,20 @@ void shouldExportCumulativeHistogramData_Timer(Duration[] buckets) { // be reported. mockClock.add(config.step()); - assertThat(getDataPoints(registry, mockClock.wallTime())).hasSize(9) - .has(gaugePoint("my.timer.avg", 0.55), atIndex(0)).has(counterPoint("my.timer.count", 4), atIndex(1)) + List dataPoints = getDataPoints(registry, mockClock.wallTime()); + assertThat(dataPoints).hasSize(9 + percentiles.length).has(gaugePoint("my.timer.avg", 0.55), atIndex(0)) + .has(counterPoint("my.timer.count", 4), atIndex(1)) .has(allOf(cumulativeCounterPoint("my.timer.histogram", 4), bucket("+Inf")), atIndex(2)) .has(allOf(cumulativeCounterPoint("my.timer.histogram", 0), bucket(buckets[0])), atIndex(3)) .has(allOf(cumulativeCounterPoint("my.timer.histogram", 1), bucket(buckets[1])), atIndex(4)) .has(allOf(cumulativeCounterPoint("my.timer.histogram", 2), bucket(buckets[2])), atIndex(5)) .has(allOf(cumulativeCounterPoint("my.timer.histogram", 3), bucket(buckets[3])), atIndex(6)) .has(gaugePoint("my.timer.max", 2), atIndex(7)) - .has(counterPoint("my.timer.totalTime", 2.2), atIndex(8)); + .has(counterPoint("my.timer.totalTime", 2.2), atIndex(8 + percentiles.length)); + if (percentiles.length > 0) { + assertThat(dataPoints).has(allOf(gaugePoint("my.timer.percentile"), percentile("0.95")), atIndex(8)) + .has(allOf(gaugePoint("my.timer.percentile"), percentile("0.99")), atIndex(9)); + } timer.record(5, TimeUnit.MILLISECONDS); timer.record(20, TimeUnit.MILLISECONDS); @@ -223,25 +229,32 @@ void shouldExportCumulativeHistogramData_Timer(Duration[] buckets) { // be reported. mockClock.add(config.step()); - assertThat(getDataPoints(registry, mockClock.wallTime())).hasSize(9) - .has(gaugePoint("my.timer.avg", 0.55), atIndex(0)).has(counterPoint("my.timer.count", 4), atIndex(1)) + dataPoints = getDataPoints(registry, mockClock.wallTime()); + assertThat(dataPoints).hasSize(9 + percentiles.length); + assertThat(dataPoints).has(gaugePoint("my.timer.avg", 0.55), atIndex(0)) + .has(counterPoint("my.timer.count", 4), atIndex(1)) .has(allOf(cumulativeCounterPoint("my.timer.histogram", 8), bucket("+Inf")), atIndex(2)) .has(allOf(cumulativeCounterPoint("my.timer.histogram", 0), bucket(buckets[0])), atIndex(3)) .has(allOf(cumulativeCounterPoint("my.timer.histogram", 2), bucket(buckets[1])), atIndex(4)) .has(allOf(cumulativeCounterPoint("my.timer.histogram", 4), bucket(buckets[2])), atIndex(5)) .has(allOf(cumulativeCounterPoint("my.timer.histogram", 6), bucket(buckets[3])), atIndex(6)) .has(gaugePoint("my.timer.max", 2), atIndex(7)) - .has(counterPoint("my.timer.totalTime", 2.2), atIndex(8)); + .has(counterPoint("my.timer.totalTime", 2.2), atIndex(8 + percentiles.length)); + if (percentiles.length > 0) { + assertThat(dataPoints).has(allOf(gaugePoint("my.timer.percentile"), percentile("0.95")), atIndex(8)) + .has(allOf(gaugePoint("my.timer.percentile"), percentile("0.99")), atIndex(9)); + } registry.close(); } @ParameterizedTest - @ArgumentsSource(TimerBuckets.class) - void shouldExportDeltaHistogramData_Timer(Duration[] buckets) { + @ArgumentsSource(TimerArguments.class) + void shouldExportDeltaHistogramData_Timer(Duration[] buckets, double[] percentiles) { MockClock mockClock = new MockClock(); SignalFxMeterRegistry registry = new SignalFxMeterRegistry(cumulativeDeltaConfig, mockClock); - Timer timer = Timer.builder("my.timer").serviceLevelObjectives(buckets).register(registry); + Timer timer = Timer.builder("my.timer").publishPercentiles(percentiles).serviceLevelObjectives(buckets) + .register(registry); timer.record(5, TimeUnit.MILLISECONDS); timer.record(20, TimeUnit.MILLISECONDS); @@ -252,15 +265,20 @@ void shouldExportDeltaHistogramData_Timer(Duration[] buckets) { // be reported. mockClock.add(config.step()); - assertThat(getDataPoints(registry, mockClock.wallTime())).hasSize(9) - .has(gaugePoint("my.timer.avg", 0.55), atIndex(0)).has(counterPoint("my.timer.count", 4), atIndex(1)) + List dataPoints = getDataPoints(registry, mockClock.wallTime()); + assertThat(dataPoints).hasSize(9 + percentiles.length).has(gaugePoint("my.timer.avg", 0.55), atIndex(0)) + .has(counterPoint("my.timer.count", 4), atIndex(1)) .has(allOf(counterPoint("my.timer.histogram", 4), bucket("+Inf")), atIndex(2)) .has(allOf(counterPoint("my.timer.histogram", 0), bucket(buckets[0])), atIndex(3)) .has(allOf(counterPoint("my.timer.histogram", 1), bucket(buckets[1])), atIndex(4)) .has(allOf(counterPoint("my.timer.histogram", 2), bucket(buckets[2])), atIndex(5)) .has(allOf(counterPoint("my.timer.histogram", 3), bucket(buckets[3])), atIndex(6)) .has(gaugePoint("my.timer.max", 2), atIndex(7)) - .has(counterPoint("my.timer.totalTime", 2.2), atIndex(8)); + .has(counterPoint("my.timer.totalTime", 2.2), atIndex(8 + percentiles.length)); + if (percentiles.length > 0) { + assertThat(dataPoints).has(allOf(gaugePoint("my.timer.percentile"), percentile("0.95")), atIndex(8)) + .has(allOf(gaugePoint("my.timer.percentile"), percentile("0.99")), atIndex(9)); + } timer.record(5, TimeUnit.MILLISECONDS); timer.record(20, TimeUnit.MILLISECONDS); @@ -271,39 +289,47 @@ void shouldExportDeltaHistogramData_Timer(Duration[] buckets) { // be reported. mockClock.add(config.step()); - assertThat(getDataPoints(registry, mockClock.wallTime())).hasSize(9) - .has(gaugePoint("my.timer.avg", 0.55), atIndex(0)).has(counterPoint("my.timer.count", 4), atIndex(1)) + dataPoints = getDataPoints(registry, mockClock.wallTime()); + assertThat(dataPoints).hasSize(9 + percentiles.length).has(gaugePoint("my.timer.avg", 0.55), atIndex(0)) + .has(counterPoint("my.timer.count", 4), atIndex(1)) .has(allOf(counterPoint("my.timer.histogram", 4), bucket("+Inf")), atIndex(2)) .has(allOf(counterPoint("my.timer.histogram", 0), bucket(buckets[0])), atIndex(3)) .has(allOf(counterPoint("my.timer.histogram", 1), bucket(buckets[1])), atIndex(4)) .has(allOf(counterPoint("my.timer.histogram", 2), bucket(buckets[2])), atIndex(5)) .has(allOf(counterPoint("my.timer.histogram", 3), bucket(buckets[3])), atIndex(6)) .has(gaugePoint("my.timer.max", 2), atIndex(7)) - .has(counterPoint("my.timer.totalTime", 2.2), atIndex(8)); + .has(counterPoint("my.timer.totalTime", 2.2), atIndex(8 + percentiles.length)); + if (percentiles.length > 0) { + assertThat(dataPoints).has(allOf(gaugePoint("my.timer.percentile"), percentile("0.95")), atIndex(8)) + .has(allOf(gaugePoint("my.timer.percentile"), percentile("0.99")), atIndex(9)); + } registry.close(); } - static final class TimerBuckets implements ArgumentsProvider { + static final class TimerArguments implements ArgumentsProvider { @Override public Stream provideArguments(ExtensionContext context) { + Object emptyPercentile = new double[0]; + Object percentile = new double[] { 0.95, 0.99 }; Object buckets = Arrays.array(Duration.ofMillis(1), Duration.ofMillis(10), Duration.ofMillis(100), Duration.ofMillis(1000)); Object bucketsWithInf = Arrays.array(Duration.ofMillis(1), Duration.ofMillis(10), Duration.ofMillis(100), Duration.ofMillis(1000), Duration.ofNanos(Long.MAX_VALUE)); - return Stream.of(Arguments.of(buckets), Arguments.of(bucketsWithInf)); + return Stream.of(Arguments.of(buckets, emptyPercentile), Arguments.of(bucketsWithInf, emptyPercentile), + Arguments.of(buckets, percentile), Arguments.of(bucketsWithInf, percentile)); } } @ParameterizedTest - @ArgumentsSource(DistributionSummaryBuckets.class) - void shouldExportCumulativeHistogramData_DistributionSummary(double[] buckets) { + @ArgumentsSource(DistributionSummaryArguments.class) + void shouldExportCumulativeHistogramData_DistributionSummary(double[] buckets, double[] percentiles) { MockClock mockClock = new MockClock(); SignalFxMeterRegistry registry = new SignalFxMeterRegistry(cumulativeHistogramConfig, mockClock); DistributionSummary distributionSummary = DistributionSummary.builder("my.distribution") - .serviceLevelObjectives(buckets).register(registry); + .publishPercentiles(percentiles).serviceLevelObjectives(buckets).register(registry); distributionSummary.record(5); distributionSummary.record(20); @@ -314,8 +340,8 @@ void shouldExportCumulativeHistogramData_DistributionSummary(double[] buckets) { // be reported. mockClock.add(cumulativeHistogramConfig.step()); - assertThat(getDataPoints(registry, mockClock.wallTime())).hasSize(9) - .has(gaugePoint("my.distribution.avg", 550), atIndex(0)) + List dataPoints = getDataPoints(registry, mockClock.wallTime()); + assertThat(dataPoints).hasSize(9 + percentiles.length).has(gaugePoint("my.distribution.avg", 550), atIndex(0)) .has(counterPoint("my.distribution.count", 4), atIndex(1)) .has(allOf(cumulativeCounterPoint("my.distribution.histogram", 4), bucket("+Inf")), atIndex(2)) .has(allOf(cumulativeCounterPoint("my.distribution.histogram", 0), bucket(buckets[0])), atIndex(3)) @@ -323,7 +349,11 @@ void shouldExportCumulativeHistogramData_DistributionSummary(double[] buckets) { .has(allOf(cumulativeCounterPoint("my.distribution.histogram", 2), bucket(buckets[2])), atIndex(5)) .has(allOf(cumulativeCounterPoint("my.distribution.histogram", 3), bucket(buckets[3])), atIndex(6)) .has(gaugePoint("my.distribution.max", 2000), atIndex(7)) - .has(counterPoint("my.distribution.totalTime", 2200), atIndex(8)); + .has(counterPoint("my.distribution.totalTime", 2200), atIndex(8 + percentiles.length)); + if (percentiles.length > 0) { + assertThat(dataPoints).has(allOf(gaugePoint("my.distribution.percentile"), percentile("0.95")), atIndex(8)) + .has(allOf(gaugePoint("my.distribution.percentile"), percentile("0.99")), atIndex(9)); + } distributionSummary.record(5); distributionSummary.record(20); @@ -334,8 +364,8 @@ void shouldExportCumulativeHistogramData_DistributionSummary(double[] buckets) { // be reported. mockClock.add(cumulativeHistogramConfig.step()); - assertThat(getDataPoints(registry, mockClock.wallTime())).hasSize(9) - .has(gaugePoint("my.distribution.avg", 550), atIndex(0)) + dataPoints = getDataPoints(registry, mockClock.wallTime()); + assertThat(dataPoints).hasSize(9 + percentiles.length).has(gaugePoint("my.distribution.avg", 550), atIndex(0)) .has(counterPoint("my.distribution.count", 4), atIndex(1)) .has(allOf(cumulativeCounterPoint("my.distribution.histogram", 8), bucket("+Inf")), atIndex(2)) .has(allOf(cumulativeCounterPoint("my.distribution.histogram", 0), bucket(buckets[0])), atIndex(3)) @@ -343,18 +373,22 @@ void shouldExportCumulativeHistogramData_DistributionSummary(double[] buckets) { .has(allOf(cumulativeCounterPoint("my.distribution.histogram", 4), bucket(buckets[2])), atIndex(5)) .has(allOf(cumulativeCounterPoint("my.distribution.histogram", 6), bucket(buckets[3])), atIndex(6)) .has(gaugePoint("my.distribution.max", 2000), atIndex(7)) - .has(counterPoint("my.distribution.totalTime", 2200), atIndex(8)); + .has(counterPoint("my.distribution.totalTime", 2200), atIndex(8 + percentiles.length)); + if (percentiles.length > 0) { + assertThat(dataPoints).has(allOf(gaugePoint("my.distribution.percentile"), percentile("0.95")), atIndex(8)) + .has(allOf(gaugePoint("my.distribution.percentile"), percentile("0.99")), atIndex(9)); + } registry.close(); } @ParameterizedTest - @ArgumentsSource(DistributionSummaryBuckets.class) - void shouldExportDeltaHistogramData_DistributionSummary(double[] buckets) { + @ArgumentsSource(DistributionSummaryArguments.class) + void shouldExportDeltaHistogramData_DistributionSummary(double[] buckets, double[] percentiles) { MockClock mockClock = new MockClock(); SignalFxMeterRegistry registry = new SignalFxMeterRegistry(cumulativeDeltaConfig, mockClock); DistributionSummary distributionSummary = DistributionSummary.builder("my.distribution") - .serviceLevelObjectives(buckets).register(registry); + .publishPercentiles(percentiles).serviceLevelObjectives(buckets).register(registry); distributionSummary.record(5); distributionSummary.record(20); @@ -365,8 +399,8 @@ void shouldExportDeltaHistogramData_DistributionSummary(double[] buckets) { // be reported. mockClock.add(cumulativeHistogramConfig.step()); - assertThat(getDataPoints(registry, mockClock.wallTime())).hasSize(9) - .has(gaugePoint("my.distribution.avg", 550), atIndex(0)) + List dataPoints = getDataPoints(registry, mockClock.wallTime()); + assertThat(dataPoints).hasSize(9 + percentiles.length).has(gaugePoint("my.distribution.avg", 550), atIndex(0)) .has(counterPoint("my.distribution.count", 4), atIndex(1)) .has(allOf(counterPoint("my.distribution.histogram", 4), bucket("+Inf")), atIndex(2)) .has(allOf(counterPoint("my.distribution.histogram", 0), bucket(buckets[0])), atIndex(3)) @@ -374,7 +408,11 @@ void shouldExportDeltaHistogramData_DistributionSummary(double[] buckets) { .has(allOf(counterPoint("my.distribution.histogram", 2), bucket(buckets[2])), atIndex(5)) .has(allOf(counterPoint("my.distribution.histogram", 3), bucket(buckets[3])), atIndex(6)) .has(gaugePoint("my.distribution.max", 2000), atIndex(7)) - .has(counterPoint("my.distribution.totalTime", 2200), atIndex(8)); + .has(counterPoint("my.distribution.totalTime", 2200), atIndex(8 + percentiles.length)); + if (percentiles.length > 0) { + assertThat(dataPoints).has(allOf(gaugePoint("my.distribution.percentile"), percentile("0.95")), atIndex(8)) + .has(allOf(gaugePoint("my.distribution.percentile"), percentile("0.99")), atIndex(9)); + } distributionSummary.record(5); distributionSummary.record(20); @@ -385,8 +423,8 @@ void shouldExportDeltaHistogramData_DistributionSummary(double[] buckets) { // be reported. mockClock.add(cumulativeHistogramConfig.step()); - assertThat(getDataPoints(registry, mockClock.wallTime())).hasSize(9) - .has(gaugePoint("my.distribution.avg", 550), atIndex(0)) + dataPoints = getDataPoints(registry, mockClock.wallTime()); + assertThat(dataPoints).hasSize(9 + percentiles.length).has(gaugePoint("my.distribution.avg", 550), atIndex(0)) .has(counterPoint("my.distribution.count", 4), atIndex(1)) .has(allOf(counterPoint("my.distribution.histogram", 4), bucket("+Inf")), atIndex(2)) .has(allOf(counterPoint("my.distribution.histogram", 0), bucket(buckets[0])), atIndex(3)) @@ -394,18 +432,25 @@ void shouldExportDeltaHistogramData_DistributionSummary(double[] buckets) { .has(allOf(counterPoint("my.distribution.histogram", 2), bucket(buckets[2])), atIndex(5)) .has(allOf(counterPoint("my.distribution.histogram", 3), bucket(buckets[3])), atIndex(6)) .has(gaugePoint("my.distribution.max", 2000), atIndex(7)) - .has(counterPoint("my.distribution.totalTime", 2200), atIndex(8)); + .has(counterPoint("my.distribution.totalTime", 2200), atIndex(8 + percentiles.length)); + if (percentiles.length > 0) { + assertThat(dataPoints).has(allOf(gaugePoint("my.distribution.percentile"), percentile("0.95")), atIndex(8)) + .has(allOf(gaugePoint("my.distribution.percentile"), percentile("0.99")), atIndex(9)); + } registry.close(); } - static final class DistributionSummaryBuckets implements ArgumentsProvider { + static final class DistributionSummaryArguments implements ArgumentsProvider { @Override public Stream provideArguments(ExtensionContext context) { + Object emptyPercentile = new double[0]; + Object percentile = new double[] { 0.95, 0.99 }; Object buckets = new double[] { 1.0, 10, 100, 1000 }; Object bucketsWithInf = new double[] { 1.0, 10, 100, 1000, Double.MAX_VALUE }; - return Stream.of(Arguments.of(buckets), Arguments.of(bucketsWithInf)); + return Stream.of(Arguments.of(buckets, emptyPercentile), Arguments.of(bucketsWithInf, emptyPercentile), + Arguments.of(buckets, percentile), Arguments.of(bucketsWithInf, percentile)); } } @@ -472,7 +517,7 @@ void shouldNotExportCumulativeHistogramDataByDefault_DistributionSummary() { } private static List getDataPoints(SignalFxMeterRegistry registry, - long timestamp) { + long timestamp) { return registry.getMeters().stream() .map(meter -> meter.match(registry::addGauge, registry::addCounter, registry::addTimer, registry::addDistributionSummary, registry::addLongTaskTimer, registry::addTimeGauge, @@ -480,7 +525,15 @@ private static List getDataPoints(SignalFxMet .flatMap(builders -> builders.map(builder -> builder.setTimestamp(timestamp).build())) .sorted(Comparator.comparing(SignalFxProtocolBuffers.DataPoint::getMetric) .thenComparing((point) -> point.getDimensions(0).getValue())) - .collect(Collectors.toList()); + .sorted((dt1, dt2) -> { + int ret1 = dt1.getMetric().compareTo(dt2.getMetric()); + if (ret1 == 0) { + if (dt1.getDimensionsCount() > 0 && dt2.getDimensionsCount() > 0) { + return dt1.getDimensions(0).getValue().compareTo(dt2.getDimensions(0).getValue()); + } + } + return ret1; + }).collect(Collectors.toList()); } private static Condition bucket(double bucket) { @@ -497,6 +550,12 @@ private static Condition bucket(String bucket "Has 'le' dimension with value %s", bucketStr)); } + private static Condition percentile(String percentileStr) { + return allOf(new Condition<>(point -> point.getDimensions(0).getKey().equals("phi"), "Has 'phi' dimension"), + new Condition<>(point -> point.getDimensions(0).getValue().equals(percentileStr), + "Has 'phi' dimension with value %s", percentileStr)); + } + private static Condition counterPoint(String name, double value) { return allOf(new Condition<>(point -> point.getMetric().equals(name), "Has name %s", name), new Condition<>(point -> point.getMetricType().equals(COUNTER), "Has COUNTER type"), hasValue(value)); @@ -510,8 +569,12 @@ private static Condition cumulativeCounterPoi } private static Condition gaugePoint(String name, double value) { + return allOf(gaugePoint(name), hasValue(value)); + } + + private static Condition gaugePoint(String name) { return allOf(new Condition<>(point -> point.getMetric().equals(name), "Has name %s", name), - new Condition<>(point -> point.getMetricType().equals(GAUGE), "Has GAUGE type"), hasValue(value)); + new Condition<>(point -> point.getMetricType().equals(GAUGE), "Has GAUGE type")); } private static Condition hasValue(double value) {