mirror of
https://github.com/prometheus/prometheus.git
synced 2025-12-04 09:01:02 +01:00
Merge pull request #17320 from prometheus/beorn7/histogram3
model/histogram: Fix checkHistogramCustomBounds to accept -Inf
This commit is contained in:
commit
2c2a4314b9
@ -468,11 +468,11 @@ func checkHistogramBuckets[BC BucketCount, IBC InternalBucketCount](buckets []IB
|
||||
|
||||
func checkHistogramCustomBounds(bounds []float64, spans []Span, numBuckets int) error {
|
||||
prev := math.Inf(-1)
|
||||
for _, curr := range bounds {
|
||||
for i, curr := range bounds {
|
||||
if math.IsNaN(curr) {
|
||||
return ErrHistogramCustomBucketsNaN
|
||||
}
|
||||
if curr <= prev {
|
||||
if i > 0 && curr <= prev {
|
||||
return fmt.Errorf("previous bound is %f and current is %f: %w", prev, curr, ErrHistogramCustomBucketsInvalid)
|
||||
}
|
||||
prev = curr
|
||||
|
||||
@ -1579,6 +1579,12 @@ func TestHistogramValidation(t *testing.T) {
|
||||
},
|
||||
errMsg: "custom buckets: last +Inf bound must not be explicitly defined: histogram custom bounds must be finite",
|
||||
},
|
||||
"valid custom buckets histogram with explicit -Inf bound": {
|
||||
h: &Histogram{
|
||||
Schema: CustomBucketsSchema,
|
||||
CustomValues: []float64{math.Inf(-1), 1},
|
||||
},
|
||||
},
|
||||
"reject custom buckets histogram with NaN bound": {
|
||||
h: &Histogram{
|
||||
Schema: CustomBucketsSchema,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user