Skip to content

Commit

Permalink
Merge branch '1.5.x' into 1.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Mar 16, 2021
2 parents 34f2a5e + 3e06732 commit fd656a7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,13 @@ public DistributionSummary newDistributionSummary(Meter.Id id, DistributionStati
sampleName, histogramKeys, histogramValues, c.count()));
}

// the +Inf bucket should always equal `count`
final List<String> histogramValues = new LinkedList<>(tagValues);
histogramValues.add("+Inf");
samples.add(new Collector.MetricFamilySamples.Sample(
sampleName, histogramKeys, histogramValues, count));
if (Double.isFinite(histogramCounts[histogramCounts.length - 1].bucket())) {
// the +Inf bucket should always equal `count`
final List<String> histogramValues = new LinkedList<>(tagValues);
histogramValues.add("+Inf");
samples.add(new Collector.MetricFamilySamples.Sample(
sampleName, histogramKeys, histogramValues, count));
}
break;
case VictoriaMetrics:
histogramKeys.add("vmrange");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,31 @@ void percentileHistogramsNeverResetForSummaries() {
.contains("s1_bucket{le=\"100.0\",} 1.0");
}

@Test
void percentileHistogramWithUpperBoundContainsExactlyOneInf() {

DistributionSummary s = DistributionSummary.builder("s")
.publishPercentileHistogram()
.maximumExpectedValue(3.0)
.register(registry);

s.record(100);

assertThat(registry.scrape()).containsOnlyOnce("s_bucket{le=\"+Inf\",} 1.0");
}

@Test
void percentileHistogramWithoutUpperBoundContainsExactlyOneInf() {

DistributionSummary s = DistributionSummary.builder("s")
.publishPercentileHistogram()
.register(registry);

s.record(100);

assertThat(registry.scrape()).containsOnlyOnce("s_bucket{le=\"+Inf\",} 1.0");
}

@Issue("#247")
@Test
void distributionPercentileBuckets() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ private static HistogramGauges getHistogramGauges(HistogramSupport histogramSupp
percentile -> Tags.concat(id.getTagsAsIterable(), "phi", DoubleFormat.decimalOrNan(percentile.percentile())),
percentile -> percentile.value(baseTimeUnit),
bucket -> id.getName() + ".histogram",
// We look for Long.MAX_VALUE to ensure a sensible tag on our +Inf bucket
bucket -> Tags.concat(id.getTagsAsIterable(), "le", bucket.isPositiveInf()
? "+Inf" : DoubleFormat.wholeOrDecimal(bucket.bucket(baseTimeUnit))));
}
Expand All @@ -77,7 +76,6 @@ public static HistogramGauges registerWithCommonFormat(DistributionSummary summa
percentile -> Tags.concat(id.getTagsAsIterable(), "phi", DoubleFormat.decimalOrNan(percentile.percentile())),
ValueAtPercentile::value,
bucket -> id.getName() + ".histogram",
// We look for Long.MAX_VALUE to ensure a sensible tag on our +Inf bucket
bucket -> Tags.concat(id.getTagsAsIterable(), "le", bucket.isPositiveInf()
? "+Inf" : DoubleFormat.wholeOrDecimal(bucket.bucket())));
}
Expand Down

0 comments on commit fd656a7

Please sign in to comment.