mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Fix decoding buckets for native histograms in binops
The optimizer which detects cases where histogram buckets can be skipped does not take into account binary expressions. This can lead to buckets not being decoded if a metric is used with both histogram_fraction/quantile and histogram_sum/count in the same expression. Signed-off-by: Filip Petkovski <filip.petkovsky@gmail.com>
This commit is contained in:
parent
d002fad00c
commit
acb6c1ae4b
|
@ -3450,6 +3450,12 @@ func setOffsetForAtModifier(evalTime int64, expr parser.Expr) {
|
|||
// required for correctness.
|
||||
func detectHistogramStatsDecoding(expr parser.Expr) {
|
||||
parser.Inspect(expr, func(node parser.Node, path []parser.Node) error {
|
||||
if n, ok := node.(*parser.BinaryExpr); ok {
|
||||
detectHistogramStatsDecoding(n.LHS)
|
||||
detectHistogramStatsDecoding(n.RHS)
|
||||
return fmt.Errorf("stop")
|
||||
}
|
||||
|
||||
n, ok := (node).(*parser.VectorSelector)
|
||||
if !ok {
|
||||
return nil
|
||||
|
|
|
@ -715,6 +715,9 @@ eval instant at 10m histogram_fraction(NaN, NaN, histogram_fraction_4)
|
|||
eval instant at 10m histogram_fraction(-Inf, +Inf, histogram_fraction_4)
|
||||
{} 1
|
||||
|
||||
eval instant at 10m histogram_sum(scalar(histogram_fraction(-Inf, +Inf, sum(histogram_fraction_4))) * histogram_fraction_4)
|
||||
{} 100
|
||||
|
||||
clear
|
||||
|
||||
# Counter reset only noticeable in a single bucket.
|
||||
|
|
Loading…
Reference in a new issue