Repository navigation
feat: Add per-metric windows to lock free metrics batcher - #8327
Open
alexander-alderman-webb wants to merge 27 commits into
Open
alexander-alderman-webb wants to merge 27 commits into
alexander-alderman-webb wants to merge 27 commits into
Conversation
Contributor
Coverage Results 📊✅ 59490 passed | ⏭️ 3035 skipped | Total: 62525 | Pass Rate: 95.15% | Execution Time: 226m 15s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 90.76% (108 of 119 changed executable lines covered; target 80%). Changed files with executable lines (2)
Coverage diff@@ Coverage Diff @@
## master #8327 +/-##
==========================================
- Coverage 90.22% 90.06% -0.16%
==========================================
Files 203 201 -2
Tracked lines 27349 22351 -4998
Branches 10252 7826 -2426
==========================================
- Hits 24675 20129 -4546
+ Misses 2674 2222 -452
+ Partials 1557 1292 -265Generated by Coverage Action |
…window-metrics-batcher-2
alexander-alderman-webb
marked this pull request as ready for review
November 19, 2026 09:11
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cb36693. Configure here.
…window-metrics-batcher-2 # Conflicts: # tests/test_metrics.py
Collaborator
Author
|
I just inlined |
This branch has not been deployed
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.

Description
Keeps window-sampled metrics in a thread-local reservoir, and performs uniform sampling once the window is no longer the active window. Segmenting metrics per thread while the window is being modified enables lock-free operations (only a thread touches its state).
Conceptually, each window has thread state, and each thread state has a reservoir of metrics.
The sum of metrics in a window computed by
_Window.size()is imprecise. It undercount the actual size as the iteration over all reservoirs is not atomic, and overcounts as threads that start writing metrics are not counted after the iteration has started.There can be multiple consumers if
sentry_sdk.flush()runs concurrently with the background flusher. This is expected and handled byIndexError.Issues
Reminders
uv run ruff.feat:,fix:,ref:,meta:)