mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
Merge pull request #2044 from prometheus/changes-nan
promql: handle NaN in changes() correctly
This commit is contained in:
commit
32d29f8dbc
|
@ -788,7 +788,7 @@ func funcChanges(ev *evaluator, args Expressions) model.Value {
|
||||||
prev := model.SampleValue(samples.Values[0].Value)
|
prev := model.SampleValue(samples.Values[0].Value)
|
||||||
for _, sample := range samples.Values[1:] {
|
for _, sample := range samples.Values[1:] {
|
||||||
current := sample.Value
|
current := sample.Value
|
||||||
if current != prev {
|
if current != prev && !(math.IsNaN(float64(current)) && math.IsNaN(float64(prev))) {
|
||||||
changes++
|
changes++
|
||||||
}
|
}
|
||||||
prev = current
|
prev = current
|
||||||
|
|
9
promql/testdata/functions.test
vendored
9
promql/testdata/functions.test
vendored
|
@ -50,6 +50,15 @@ eval instant at 50m changes(http_requests[50m])
|
||||||
|
|
||||||
eval instant at 50m changes(nonexistent_metric[50m])
|
eval instant at 50m changes(nonexistent_metric[50m])
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
load 5m
|
||||||
|
x{a="b"} NaN NaN NaN
|
||||||
|
x{a="c"} 0 NaN 0
|
||||||
|
|
||||||
|
eval instant at 15m changes(x[15m])
|
||||||
|
{a="b"} 0
|
||||||
|
{a="c"} 2
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue