prometheus/promql
Joshua Hesketh 5a4e4f6936
Fix stddev/stdvar when aggregating histograms, NaNs, and infinities (#14941)
promql: Fix stddev/stdvar when aggregating histograms, NaNs, and Infs

Native histograms are ignored when calculating stddev or stdvar.

However, for the first series of each group, a `groupedAggregation` is
always created. If the first series that was encountered is a histogram
then it acts as the equivalent of a 0 point.

This change creates the first `groupedAggregation` with the `seen` field set to `false` if the point is a
histogram, thus ignoring it like the rest of the aggregation function does. A new `groupedAggregation`
will then be created once an actual float value is encountered.

This commit also sets the `floatValue` field of the `groupedAggregation` to `NaN`, if the first
float value of a group is `NaN` or `±Inf`, so that the outcome is consistently `NaN` once those
values are in the mix.

(The added tests fail without this change).

Signed-off-by: Joshua Hesketh <josh@nitrotech.org>
Signed-off-by: beorn7 <beorn@grafana.com>

---------

Signed-off-by: Joshua Hesketh <josh@nitrotech.org>
Signed-off-by: beorn7 <beorn@grafana.com>
Co-authored-by: beorn7 <beorn@grafana.com>
2024-10-16 15:00:46 +02:00
..
fuzz-data textparse: Add fuzzing and fix bug caught 2017-07-07 11:12:17 +02:00
parser fix: use "ErrorContains" or "EqualError" instead of "Contains(t, err.Error()" and "Equal(t, err.Error()" (#15094) 2024-10-06 16:35:29 +00:00
promqltest Fix stddev/stdvar when aggregating histograms, NaNs, and infinities (#14941) 2024-10-16 15:00:46 +02:00
bench_test.go promql: rename holt_winters to double_exponential_smoothing 2024-09-19 15:29:01 +02:00
engine.go Fix stddev/stdvar when aggregating histograms, NaNs, and infinities (#14941) 2024-10-16 15:00:46 +02:00
engine_internal_test.go chore!: adopt log/slog, remove go-kit/log 2024-10-07 15:58:50 -04:00
engine_test.go chore!: adopt log/slog, remove go-kit/log 2024-10-07 15:58:50 -04:00
functions.go [REFACTOR] PromQL: remove label_join and label_replace stubs 2024-09-27 11:20:45 +01:00
functions_internal_test.go Fix issue where summation of +/- infinity returns NaN instead of infinity 2024-06-28 11:26:54 +10:00
functions_test.go Refactor engine creation in tests 2024-07-14 13:58:51 +02:00
fuzz.go change: No longer ingest OM _created as timeseries if feature-flag 'enable-ct-zero-ingestion' is enabled; fixed OM text CT conversion bug (#14738) 2024-10-02 11:52:03 +01:00
fuzz_test.go fix: use "ErrorContains" or "EqualError" instead of "Contains(t, err.Error()" and "Equal(t, err.Error()" (#15094) 2024-10-06 16:35:29 +00:00
histogram_stats_iterator.go Use CopyTo when resetting histogram in stats iterator 2024-07-31 11:18:47 +02:00
histogram_stats_iterator_test.go Add more test cases 2024-07-29 14:53:32 +02:00
promql_test.go Refactor engine creation in tests 2024-07-14 13:58:51 +02:00
quantile.go promql(native histograms): Introduce exponential interpolation 2024-09-19 14:19:10 +02:00
quantile_test.go PromQL: ignore small errors for bucketQuantile (#13153) 2023-11-25 00:05:38 +01:00
query_logger.go chore!: adopt log/slog, remove go-kit/log 2024-10-07 15:58:50 -04:00
query_logger_test.go chore: Fix typos (#14868) 2024-09-10 22:32:03 +02:00
value.go chore: Fix typos (#14868) 2024-09-10 22:32:03 +02:00
value_test.go test: move most PromQL tests into separate test package 2024-05-08 16:28:56 +01:00