Merge pull request #91777 from ahg-g/ahg-hist

Added +inf bucket for quantile computations
This commit is contained in:
Kubernetes Prow Robot 2020-06-04 13:53:26 -07:00 committed by GitHub
commit d6b42f0049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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 if len(buckets) == 0 || buckets[len(buckets)-1].upperBound != math.Inf(+1) {
// 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) return bucketQuantile(q, buckets)
} }