Skip to content

Commit 5296dd2

Browse files
committed
Added +inf bucket for quantile computations
1 parent e422e9a commit 5296dd2

File tree

1 file changed

+8
-2
lines changed
  • staging/src/k8s.io/component-base/metrics/testutil

1 file changed

+8
-2
lines changed

staging/src/k8s.io/component-base/metrics/testutil/metrics.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,14 @@ func (hist *Histogram) Quantile(q float64) float64 {
286286
})
287287
}
288288

289-
// bucketQuantile expects the upper bound of the last bucket to be +inf
290-
// buckets[len(buckets)-1].upperBound = math.Inf(+1)
289+
if len(buckets) == 0 || buckets[len(buckets)-1].upperBound != math.Inf(+1) {
290+
// The list of buckets in dto.Histogram doesn't include the final +Inf bucket, so we
291+
// add it here for the reset of the samples.
292+
buckets = append(buckets, bucket{
293+
count: float64(hist.GetSampleCount()),
294+
upperBound: math.Inf(+1),
295+
})
296+
}
291297

292298
return bucketQuantile(q, buckets)
293299
}

0 commit comments

Comments
 (0)