Added +inf bucket for quantile computations

This commit is contained in:
Abdullah Gharaibeh 2020-06-04 10:44:29 -04:00
parent e422e9a3f4
commit 5296dd2953

View File

@ -286,8 +286,14 @@ func (hist *Histogram) Quantile(q float64) float64 {
})
}
// bucketQuantile expects the upper bound of the last bucket to be +inf
// buckets[len(buckets)-1].upperBound = math.Inf(+1)
if len(buckets) == 0 || buckets[len(buckets)-1].upperBound != math.Inf(+1) {
// The list of buckets in dto.Histogram doesn't include the final +Inf bucket, so we
// add it here for the reset of the samples.
buckets = append(buckets, bucket{
count: float64(hist.GetSampleCount()),
upperBound: math.Inf(+1),
})
}
return bucketQuantile(q, buckets)
}