mirror of
https://github.com/prometheus/prometheus.git
synced 2026-02-18 18:25:24 -05:00
Merge pull request #18058 from zenador/fix-avg-over-time-nh
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (push) Waiting to run
CI / Build Prometheus for all architectures (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
Some checks are pending
buf.build / lint and publish (push) Waiting to run
CI / Go tests (push) Waiting to run
CI / More Go tests (push) Waiting to run
CI / Go tests with previous Go version (push) Waiting to run
CI / UI tests (push) Waiting to run
CI / Go tests on Windows (push) Waiting to run
CI / Mixins tests (push) Waiting to run
CI / Build Prometheus for common architectures (push) Waiting to run
CI / Build Prometheus for all architectures (push) Waiting to run
CI / Report status of build Prometheus for all architectures (push) Blocked by required conditions
CI / Check generated parser (push) Waiting to run
CI / golangci-lint (push) Waiting to run
CI / fuzzing (push) Waiting to run
CI / codeql (push) Waiting to run
CI / Publish main branch artifacts (push) Blocked by required conditions
CI / Publish release artefacts (push) Blocked by required conditions
CI / Publish UI on npm Registry (push) Blocked by required conditions
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
promql: fix avg_over_time for single native histogram
This commit is contained in:
commit
b84d7dcc56
2 changed files with 16 additions and 1 deletions
|
|
@ -848,7 +848,7 @@ func funcAvgOverTime(_ []Vector, matrixVal Matrix, args parser.Expressions, enh
|
|||
var (
|
||||
sum = s.Histograms[0].H.Copy()
|
||||
mean, kahanC *histogram.FloatHistogram
|
||||
count float64
|
||||
count = 1.
|
||||
incrementalMean bool
|
||||
nhcbBoundsReconciled bool
|
||||
err error
|
||||
|
|
|
|||
|
|
@ -1545,6 +1545,21 @@ eval instant at 3m avg_over_time(histogram_sum_over_time_incremental_6[4m:1m])
|
|||
|
||||
clear
|
||||
|
||||
# Test avg_over_time with a single histogram sample (regression test for division by zero bug).
|
||||
load 1m
|
||||
single_histogram_sample {{schema:3 sum:5 count:4 buckets:[1 2 1]}}
|
||||
single_nhcb_sample {{schema:-53 sum:1 count:5 custom_values:[5 10] buckets:[1 4]}}
|
||||
|
||||
# avg_over_time should return the histogram unchanged when there's only one sample, not Inf/NaN.
|
||||
eval instant at 0m avg_over_time(single_histogram_sample[1m])
|
||||
{} {{schema:3 sum:5 count:4 buckets:[1 2 1]}}
|
||||
|
||||
# Test with native histogram with custom buckets (NHCB).
|
||||
eval instant at 0m avg_over_time(single_nhcb_sample[1m])
|
||||
{} {{schema:-53 sum:1 count:5 custom_values:[5 10] buckets:[1 4]}}
|
||||
|
||||
clear
|
||||
|
||||
# Test native histograms with sub operator.
|
||||
load 10m
|
||||
histogram_sub_1{idx="0"} {{schema:0 count:41 sum:2345.6 z_bucket:5 z_bucket_w:0.001 buckets:[1 3 1 2 1 1 1] n_buckets:[0 1 4 2 7 0 0 0 0 5 5 2]}}x1
|
||||
|
|
|
|||
Loading…
Reference in a new issue