mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Round function 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
6ce21b8399
commit
14ef1ce8ab
|
@ -551,6 +551,10 @@ func funcRound(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper
|
||||||
toNearestInverse := 1.0 / toNearest
|
toNearestInverse := 1.0 / toNearest
|
||||||
|
|
||||||
for _, el := range vec {
|
for _, el := range vec {
|
||||||
|
if el.H != nil {
|
||||||
|
// Process only float samples.
|
||||||
|
continue
|
||||||
|
}
|
||||||
f := math.Floor(el.F*toNearestInverse+0.5) / toNearestInverse
|
f := math.Floor(el.F*toNearestInverse+0.5) / toNearestInverse
|
||||||
enh.Out = append(enh.Out, Sample{
|
enh.Out = append(enh.Out, Sample{
|
||||||
Metric: el.Metric,
|
Metric: el.Metric,
|
||||||
|
|
9
promql/promqltest/testdata/functions.test
vendored
9
promql/promqltest/testdata/functions.test
vendored
|
@ -1258,3 +1258,12 @@ load 1m
|
||||||
# We expect the value to be 0 for t=0s to t=59s (inclusive), then 60 for t=60s and t=61s.
|
# We expect the value to be 0 for t=0s to t=59s (inclusive), then 60 for t=60s and t=61s.
|
||||||
eval range from 0 to 61s step 1s timestamp(metric)
|
eval range from 0 to 61s step 1s timestamp(metric)
|
||||||
{} 0x59 60 60
|
{} 0x59 60 60
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
# Check round with mixed data types
|
||||||
|
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]}}
|
||||||
|
|
||||||
|
eval range from 0 to 5m step 1m round(mixed_metric)
|
||||||
|
{} _ 1 2 3
|
||||||
|
|
Loading…
Reference in a new issue