prometheus/promql
Bartlomiej Plotka a0df8a383a
promql: Removed global and add ability to have better interval for subqueries if not specified (#7628)
* promql: Removed global and add ability to have better interval for subqueries if not specified

## Changes
* Refactored tests for better hints testing
* Added various TODO in places to enhance.
* Moved DefaultEvalInterval global to opts with func(rangeMillis int64) int64 function instead

Motivation: At Thanos we would love to have better control over the subqueries step/interval.
This is important to choose proper resolution. I think having proper step also does not harm for
Prometheus and remote read users. Especially on stateless querier we do not know evaluation interval
and in fact putting global can be wrong to assume for Prometheus even.

I think ideally we could try to have at least 3 samples within the range, the same
way Prometheus UI and Grafana assumes.

Anyway this interfaces allows to decide on promQL user basis.

Open question: Is taking parent interval a smart move?

Motivation for removing global: I spent 1h fighting with:


=== RUN   TestEvaluations
    TestEvaluations: promql_test.go:31: unexpected error: error evaluating query "absent_over_time(rate(nonexistant[5m])[5m:])" (line 687): unexpected error: runtime error: integer divide by zero
--- FAIL: TestEvaluations (0.32s)
FAIL

At the end I found that this fails on most of the versions including this master if you run this test alone. If run together with many
other tests it passes. This is due to SetDefaultEvaluationInterval(1 * time.Minute)
in test that is ran before TestEvaluations. Thanks to globals (:

Let's fix it by dropping this global.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Added issue links for TODOs.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>

* Removed irrelevant changes.

Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2020-07-22 14:39:51 +01:00
..
fuzz-data textparse: Add fuzzing and fix bug caught 2017-07-07 11:12:17 +02:00
parser Fix incorrect arguments order in TestExprString (#7602) 2020-07-17 13:38:04 +01:00
testdata Fix avg_over_time for nan and float64 overflows (#7346) 2020-07-13 17:30:50 +02:00
bench_test.go Merge branch 'master' into split_parser 2020-02-19 15:18:13 +01:00
engine_test.go promql: Removed global and add ability to have better interval for subqueries if not specified (#7628) 2020-07-22 14:39:51 +01:00
engine.go promql: Removed global and add ability to have better interval for subqueries if not specified (#7628) 2020-07-22 14:39:51 +01:00
functions_test.go Bartek's suggestions 2020-02-25 13:57:30 +01:00
functions.go Fix avg_over_time for nan and float64 overflows (#7346) 2020-07-13 17:30:50 +02:00
fuzz.go Fuzz: limit input size (#7317) 2020-05-31 09:42:56 +02:00
promql_test.go Addressed comments. 2020-02-17 18:03:57 +00:00
quantile.go Fix off-by-one error in funcHistogramQuantile / ensureMonotonic (#7393) 2020-06-15 11:32:10 +01:00
query_logger_test.go promql: make active query tracker context-aware (#6701) 2020-01-27 22:29:44 +00:00
query_logger.go Remove MaxConcurrent from the PromQL engine opts (#6712) 2020-01-28 20:38:49 +00:00
test_test.go *: Consistent Error/Warning handling for SeriesSet iterator: Allowing Async Select (#7251) 2020-06-09 17:57:31 +01:00
test.go promql: Removed global and add ability to have better interval for subqueries if not specified (#7628) 2020-07-22 14:39:51 +01:00
value.go Merge branch 'master' into split_parser 2020-02-19 15:18:13 +01:00