Skip to content

feat: Add per-metric windows to lock free metrics batcher - #8327

Open
alexander-alderman-webb wants to merge 51 commits into
webb/sliding-window-metrics-batcherfrom
webb/sliding-window-metrics-batcher-2
Open

alexander-alderman-webb wants to merge 51 commits into
webb/sliding-window-metrics-batcherfrom
webb/sliding-window-metrics-batcher-2

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

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.

There can be multiple consumers if sentry_sdk.flush() runs concurrently with the background flusher. This is expected and handled by IndexError.

Issues

Reminders

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 59761 passed | ⏭️ 3119 skipped | Total: 62880 | Pass Rate: 95.04% | Execution Time: 164m 47s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +304
Passed Tests 📈 +304
Failed Tests —
Skipped Tests —

All tests are passing successfully.

✅ Patch coverage is 89.31% (117 of 131 changed executable lines covered; target 80%).
Project statement coverage is 90.10% (down 0.01 percentage points from base (b976ff3) to head (e3f191d)).

Changed files with executable lines (3)
File Patch coverage Changed executable lines
sentry_sdk/_lock_free_metrics_batcher.py 90.83% 99/109 covered; missed: 88, 89, 135, 136, 141, 142, 151, 180, 214, 215; partial branches: 134, 140, 145, 179
sentry_sdk/client.py 80.95% 17/21 covered; missed: 144, 149, 153, 161; partial branches: 136, 138, 152
sentry_sdk/consts.py 100.00% 1/1 covered
Coverage diff
@@            Coverage Diff             @@
##        master     #8327       +/-##
==========================================
- Coverage    90.11%    90.10%    -0.01%
==========================================
  Files          201       202        +1
  Tracked lines     22199     22461      +262
  Branches      7784      7866       +82
==========================================
+ Hits         20004     20238      +234
- Misses        2195      2223       +28
- Partials      1283      1300       +17

Generated by Coverage Action

@alexander-alderman-webb alexander-alderman-webb changed the title feat: Add sliding window to lock free metrics batcher feat: Add per-metric windows to lock free metrics batcher Nov 18, 2026
@alexander-alderman-webb
alexander-alderman-webb marked this pull request as ready for review November 19, 2026 09:11
@alexander-alderman-webb
alexander-alderman-webb requested a review from a team as a code owner November 19, 2026 09:11

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3b40b5b. Configure here.

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit e3f191d.

Main concerns: data sent to Sentry, public contract, host performance.

Rules that block low also fired:

  • R5: dependencies or bundled SDK versions changed: setup.py
  • R6: build or release configuration changed: setup.py

This label is a hint for reviewers, not an approval.

@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants