mirror of
https://github.com/prometheus/prometheus
synced 2026-04-30 23:11:34 +08:00
Handle zero_bucket_only case (plus more tests)
Signed-off-by: Linas Medziunas <linas.medziunas@gmail.com>
This commit is contained in:
@@ -3233,10 +3233,10 @@ func computeZeroBucketTrim(zeroBucket histogram.Bucket[float64], rhs float64, ha
|
||||
lower = zeroBucket.Lower
|
||||
upper = zeroBucket.Upper
|
||||
)
|
||||
if !hasPositive {
|
||||
if hasNegative && !hasPositive {
|
||||
upper = 0
|
||||
}
|
||||
if !hasNegative {
|
||||
if hasPositive && !hasNegative {
|
||||
lower = 0
|
||||
}
|
||||
|
||||
|
||||
@@ -1980,6 +1980,41 @@ eval instant at 1m h_negative_buckets >/ 0
|
||||
h_negative_buckets {{schema:0 z_bucket_w:0.5}}
|
||||
|
||||
|
||||
# Exponential buckets: trim zero bucket when there are no other buckets.
|
||||
load 1m
|
||||
zero_bucket_only {{schema:0 count:5 sum:0 z_bucket:5 z_bucket_w:0.1 }}
|
||||
|
||||
eval instant at 1m zero_bucket_only >/ 0.1
|
||||
zero_bucket_only {{schema:0 count:0 sum:0 z_bucket:0 z_bucket_w:0.1 }}
|
||||
|
||||
eval instant at 1m zero_bucket_only </ 0.1
|
||||
zero_bucket_only {{schema:0 count:5 sum:0 z_bucket:5 z_bucket_w:0.1 }}
|
||||
|
||||
eval instant at 1m zero_bucket_only >/ 0.05
|
||||
zero_bucket_only {{schema:0 count:1.25 sum:0.09375000000000001 z_bucket:1.25 z_bucket_w:0.1 }}
|
||||
|
||||
eval instant at 1m zero_bucket_only </ 0.05
|
||||
zero_bucket_only {{schema:0 count:3.75 sum:-0.09375000000000001 z_bucket:3.75 z_bucket_w:0.1 }}
|
||||
|
||||
eval instant at 1m zero_bucket_only >/ 0
|
||||
zero_bucket_only {{schema:0 count:2.5 sum:0.125 z_bucket:2.5 z_bucket_w:0.1 }}
|
||||
|
||||
eval instant at 1m zero_bucket_only </ 0
|
||||
zero_bucket_only {{schema:0 count:2.5 sum:-0.125 z_bucket:2.5 z_bucket_w:0.1 }}
|
||||
|
||||
eval instant at 1m zero_bucket_only >/ -0.05
|
||||
zero_bucket_only {{schema:0 count:3.75 sum:0.09375000000000001 z_bucket:3.75 z_bucket_w:0.1 }}
|
||||
|
||||
eval instant at 1m zero_bucket_only </ -0.05
|
||||
zero_bucket_only {{schema:0 count:1.25 sum:-0.09375000000000001 z_bucket:1.25 z_bucket_w:0.1 }}
|
||||
|
||||
eval instant at 1m zero_bucket_only </ -0.1
|
||||
zero_bucket_only {{schema:0 count:0 sum:0 z_bucket:0 z_bucket_w:0.1 }}
|
||||
|
||||
eval instant at 1m zero_bucket_only >/ -0.1
|
||||
zero_bucket_only {{schema:0 count:5 sum:0 z_bucket:5 z_bucket_w:0.1 }}
|
||||
|
||||
|
||||
load 1m
|
||||
cbh {{schema:-53 sum:172.5 count:15 custom_values:[5 10 15 20] buckets:[1 6 4 3 1]}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user