Skip to content

Commit

Permalink
Update note on ph values
Browse files Browse the repository at this point in the history
  • Loading branch information
jhesketh committed Nov 27, 2024
1 parent 448118c commit 2de496b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/streamingpromql/operators/functions/histograms.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ func (h *HistogramFunctionOverInstantVector) computeOutputSeriesForGroup(g *buck
if math.IsNaN(ph) || ph < 0 || ph > 1 {
// Even when ph is invalid we still return a series as BucketQuantile will return +/-Inf.
// So don't skip/continue the series, just emit a warning.
// Additionally, even if a point isn't returned, an annotation is emitted if ph is invalid
// at any step.
h.annotations.Add(annotations.NewInvalidQuantileWarning(ph, h.phArg.ExpressionPosition()))
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/streamingpromql/testdata/ours/classic_histograms.test
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ eval_warn range from 0m to 24m step 6m histogram_quantile(scalar(ph), series)

clear

# Test for invalid ph value where no points
load 6m
series{le="0"} 0 _ 0
series{le="2"} 1 _ 1
series{le="4"} 2 _ 2
series{le="6"} 3 _ 3
series{le="+Inf"} 3 _ 3
ph 0.5 NaN 0.9

# Both engines output a warning even though there is no point where ph is also invalid.
eval_warn range from 0m to 12m step 6m histogram_quantile(scalar(ph), series)
{} 3 _ 5.4

clear

# Test various mixed metric scenarios
load 6m
series{host="a", le="0.1"} 2 _ 1 {{schema:0 sum:5 count:4 buckets:[2 2 2]}}
Expand Down

0 comments on commit 2de496b

Please sign in to comment.