Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQE: Add support for histogram_quantile #9929

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jhesketh
Copy link
Contributor

Also preps support for more classic histogram functions to come. (Will require some re-work, but the basics are there).

Tidies up annotation tests and checks their results between engines. (Since sometimes we emit annotations with results, and sometimes the results are omitted when there is an annotation).

What this PR does

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@jhesketh jhesketh requested review from stevesg, grafanabot and a team as code owners November 18, 2024 00:36
Also preps support for more classic histogram functions to come.
(Will require some re-work, but the basics are there).

Tidies up annotation tests and checks their results between engines.
(Since sometimes we emit annotations with results, and sometimes the
results are omitted when there is an annotation).
@jhesketh jhesketh force-pushed the jhesketh/mqe-histogram-quantile branch from 38d1a77 to d293f3a Compare November 18, 2024 00:40
@jhesketh jhesketh force-pushed the jhesketh/mqe-histogram-quantile branch from d89bbab to 78fc811 Compare November 18, 2024 05:45
@jhesketh jhesketh force-pushed the jhesketh/mqe-histogram-quantile branch from 78fc811 to 5abeee0 Compare November 18, 2024 05:46
Copy link
Contributor

@charleskorn charleskorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still working my way through the implementation and will keep going tomorrow - I have some suggestions for the tests in the meantime

@@ -295,7 +295,7 @@ func TestOurTestCases(t *testing.T) {
prometheusEngine := promql.NewEngine(opts.CommonOpts)

testdataFS := os.DirFS("./testdata")
testFiles, err := fs.Glob(testdataFS, "ours*/*.test")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has the asterisk been removed? We want to run tests from both the ours and ours-only directories.

`
// TODO add series with malformed le?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this TODO still valid?

Comment on lines +2330 to +2333
// Because we test a huge amount of combinations, if we get a failure, stop running the other tests.
// This will reduce the output to make it easier to manage.
shouldStop := false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functionality is built into go test: use go test -failfast.

}

func getMixedMetricsForTests() ([]string, int, string) {
func getMixedMetricsForTests(includeClassicHistograms bool) ([]string, int, string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like includeClassicHistograms is always true - is this needed?

results = append(results, res)

_, infos := res.Warnings.AsStrings(testCase.expr, 0, 0)
//require.ElementsMatch(t, testCase.expectedWarningAnnotations, warnings)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be commented out?

"bad bucket label warning": {
data: mixedClassicHistograms,
expr: `histogram_quantile(0.5, series{host="c"})`,
expectedWarningAnnotations: []string{"PromQL warning: bucket label \"le\" is missing or has a malformed value of \"abc\" for metric name \"series\" (1:25)"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Might be clearer to use raw strings here to avoid the need for all the escaping

@@ -1836,11 +1836,82 @@ func (t *timeoutTestingQueryTracker) Close() error {
return nil
}

func TestAnnotations(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you've split this test in half?

Comment on lines +1902 to +1907
// If both results are available, compare them (sometimes we skip prometheus)
if len(results) == 2 {
// We do this extra comparison to ensure that we don't skip a series that may be outputted during a warning
// or vice-versa where no result may be expected etc.
testutils.RequireEqualResults(t, testCase.expr, results[0], results[1])
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to compare the results when we're testing annotations? I'd expect the results to be exercised elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a test for the case where the buckets for an output series change over time (eg. at T=1, buckets are 1, 2 and 5, but at T=2, buckets are 1, 3 and 7).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants