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 delta function #9795

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

Conversation

lamida
Copy link
Contributor

@lamida lamida commented Nov 1, 2024

What this PR does

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

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

@lamida lamida marked this pull request as ready for review November 10, 2024 18:28
@lamida lamida requested a review from a team as a code owner November 10, 2024 18:28
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 some tests for delta over native histograms?

It'd be good include native histograms with custom buckets, as well as scenarios that trigger the various annotations. (Have a look at our tests for rate and increase for some inspiration, and look at TestAnnotations in engine_test.go.)

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 also add some tests for the case where the value (float or histogram) increases and decreases during the range, to ensure that we're correctly ignoring resets?

val := calculateHistogramRate(isRate, step.RangeStart, step.RangeEnd, rangeSeconds, firstPoint, lastPoint, delta, hCount)
return val, err
}
return delta, err
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is quite right - the docs for delta say:

delta(v range-vector) calculates the difference between the first and last value of each time series element in a range vector v, returning an instant vector with the given deltas and equivalent labels. The delta is extrapolated to cover the full time range as specified in the range vector selector...

I see two issues with the implementation here:

  • we're not doing extrapolation
  • we're considering resets in delta, but we want to consider just the first and last value

I wonder if it would be clearer and simpler for delta to not use rate above, and instead be implemented separately and call calculateFloatRate and calculateHistogramRate to perform extrapolation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I was looking at how prometheus engine was implementing delta. But let me check at this again and try to apply your suggestion.

@lamida lamida force-pushed the lamida/mqe-delta-function branch 2 times, most recently from 9ef52f2 to b4c6a45 Compare November 11, 2024 07:14
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
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