feat: use time-unbiased algorithm for histogram reservoir#8306
Draft
dashpole wants to merge 3 commits into
Draft
feat: use time-unbiased algorithm for histogram reservoir#8306dashpole wants to merge 3 commits into
dashpole wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8306 +/- ##
=====================================
Coverage 82.9% 82.9%
=====================================
Files 314 315 +1
Lines 24985 25005 +20
=====================================
+ Hits 20730 20749 +19
Misses 3882 3882
- Partials 373 374 +1
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the SDK metric exemplar reservoirs to use a time-unbiased reservoir sampling approach (Algorithm L) for histogram buckets, while factoring the sampling logic into a shared nextTracker used by both histogram and fixed-size reservoirs.
Changes:
- Introduces
nextTrackerimplementing Algorithm L and reuses it across reservoirs. - Updates
FixedSizeReservoirandHistogramReservoirto usenextTracker-based sampling and refactors storage/locking accordingly. - Adds a statistical test asserting time-unbiased behavior for the histogram reservoir.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/metric/exemplar/storage.go | Removes the old shared storage wrapper and moves storage logic onto measurement. |
| sdk/metric/exemplar/next_tracker.go | Adds the shared Algorithm L sampling tracker. |
| sdk/metric/exemplar/histogram_reservoir.go | Switches histogram reservoir sampling from “last seen” to Algorithm L per bucket. |
| sdk/metric/exemplar/histogram_reservoir_test.go | Adds a statistical test to validate time-unbiased sampling behavior. |
| sdk/metric/exemplar/fixed_size_reservoir.go | Refactors fixed-size reservoir to use nextTracker and inline storage. |
| sdk/metric/exemplar/fixed_size_reservoir_test.go | Updates tests to reflect the new internal storage layout. |
| sdk/metric/exemplar/benchmark_test.go | Updates benchmark reset logic to use the new tracker. |
beb31f5 to
0211b4d
Compare
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.
Fixes #8236
Factors out algorithm L into a nextTracker, and uses it for both the histogram reservoir and the fixed-size reservoir.
Benchmarks:
Gemini helped write this.
I'll wait to mark this ready for review until after #8309