mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
Clamp functions should ignore native histograms
As per the documentation, native histograms are skipped. This is in line with other `simpleFunc`'s. Signed-off-by: Joshua Hesketh <josh@nitrotech.org>
This commit is contained in:
parent
d4b1f9eb33
commit
31d19381f6
|
@ -492,6 +492,10 @@ func funcClamp(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper
|
|||
return enh.Out, nil
|
||||
}
|
||||
for _, el := range vec {
|
||||
if el.H != nil {
|
||||
// Process only float samples.
|
||||
continue
|
||||
}
|
||||
if !enh.enableDelayedNameRemoval {
|
||||
el.Metric = el.Metric.DropMetricName()
|
||||
}
|
||||
|
@ -509,6 +513,10 @@ func funcClampMax(vals []parser.Value, args parser.Expressions, enh *EvalNodeHel
|
|||
vec := vals[0].(Vector)
|
||||
maxVal := vals[1].(Vector)[0].F
|
||||
for _, el := range vec {
|
||||
if el.H != nil {
|
||||
// Process only float samples.
|
||||
continue
|
||||
}
|
||||
if !enh.enableDelayedNameRemoval {
|
||||
el.Metric = el.Metric.DropMetricName()
|
||||
}
|
||||
|
@ -526,6 +534,10 @@ func funcClampMin(vals []parser.Value, args parser.Expressions, enh *EvalNodeHel
|
|||
vec := vals[0].(Vector)
|
||||
minVal := vals[1].(Vector)[0].F
|
||||
for _, el := range vec {
|
||||
if el.H != nil {
|
||||
// Process only float samples.
|
||||
continue
|
||||
}
|
||||
if !enh.enableDelayedNameRemoval {
|
||||
el.Metric = el.Metric.DropMetricName()
|
||||
}
|
||||
|
|
15
promql/promqltest/testdata/functions.test
vendored
15
promql/promqltest/testdata/functions.test
vendored
|
@ -452,6 +452,21 @@ eval instant at 0m clamp(test_clamp, NaN, 0)
|
|||
|
||||
eval instant at 0m clamp(test_clamp, 5, -5)
|
||||
|
||||
clear
|
||||
|
||||
load 1m
|
||||
mixed_metric {{schema:0 sum:5 count:4 buckets:[1 2 1]}} 1 2 3 {{schema:0 sum:5 count:4 buckets:[1 2 1]}} {{schema:0 sum:8 count:6 buckets:[1 4 1]}}
|
||||
|
||||
# clamp ignores any histograms
|
||||
eval range from 0 to 5m step 1m clamp(mixed_metric, 2, 5)
|
||||
{} _ 2 2 3
|
||||
|
||||
eval range from 0 to 5m step 1m clamp_min(mixed_metric, 2)
|
||||
{} _ 2 2 3
|
||||
|
||||
eval range from 0 to 5m step 1m clamp_max(mixed_metric, 2)
|
||||
{} _ 1 2 2
|
||||
|
||||
# Test cases for sgn.
|
||||
clear
|
||||
load 5m
|
||||
|
|
Loading…
Reference in a new issue