Fix hardcoded metricstore ES extended lookback - #9102
Open
HESleagacy wants to merge 9 commits into
Open
Conversation
The extendedStartTime for Elasticsearch range queries was hardcoded to 10 minutes prior to startTime. When a client queries metrics with RatePer larger than 10 minutes (e.g., RatePer = 30m or 1h), the initial metric window fails to find preceding data points, producing NaN rates for the first portion of the graph. This fix dynamically computes extendedStartTime based on params.RatePer and adds a nil check for RatePer. It also includes comprehensive test coverage for calculateTimeRange and updates the error case tests. Signed-off-by: Sarva Dubey <sarvadubey@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9102 +/- ##
=======================================
Coverage 97.80% 97.80%
=======================================
Files 377 377
Lines 19728 19728
=======================================
Hits 19295 19295
Misses 293 293
Partials 140 140
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
@yurishkuro Please take a look |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The extendedStartTime for Elasticsearch range queries was hardcoded to 10 minutes prior to startTime. When a client queries metrics with RatePer larger than 10 minutes (e.g., RatePer = 30m or 1h), the initial metric window fails to find preceding data points, producing NaN rates for the first portion of the graph.
This fix dynamically computes extendedStartTime based on params.RatePer and adds a nil check for RatePer. It also includes comprehensive test coverage for calculateTimeRange and updates the error case tests.
Which problem is this PR solving?
Description of the changes
extendedStartTimeusing*params.RatePer.RatePerto thenilguard incalculateTimeRangeand update the error message.timeimport inreader.go.calculateTimeRangetotime_range_test.gocoveringniledge cases and multipleRatePerwindow variations.nil RatePererror test inreader_test.go.How was this change tested?
time_range_test.gofor explicit unit testing.reader_test.gosnapshot and error tests pass.make testpasses successfully.Checklist
AI Usage in this PR (choose one)
See AI Usage Policy.