Skip to content

chore: Move locks into batcher subclasses - #8325

Open
alexander-alderman-webb wants to merge 5 commits into
masterfrom
webb/lock-free-base
Open

alexander-alderman-webb wants to merge 5 commits into
masterfrom
webb/lock-free-base

Conversation

@alexander-alderman-webb

Copy link
Copy Markdown
Collaborator

Move everything that relies on Batcher._lock into subclasses to enable writing a lock-free metrics batcher.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 59457 passed | ⏭️ 3119 skipped | Total: 62576 | Pass Rate: 95.02% | Execution Time: 157m 36s

📊 Comparison with Base Branch

Metric Change
Total Tests —
Passed Tests —
Failed Tests —
Skipped Tests —

✨ Test counts unchanged from base.

All tests are passing successfully.

✅ Patch coverage is 82.03% (105 of 128 changed executable lines covered; target 80%).
Project statement coverage is 90.13% (up 0.02 percentage points from base (edb9135) to head (5dee353)).

Changed files with executable lines (4)
File Patch coverage Changed executable lines
sentry_sdk/_metrics_batcher.py 83.33% 45/54 covered; missed: 34, 35, 42, 52, 61, 64, 65, 76, 81; partial branches: 41, 51, 75, 80
sentry_sdk/_log_batcher.py 85.19% 46/54 covered; missed: 34, 35, 42, 52, 61, 64, 65, 81; partial branches: 41, 51, 80
sentry_sdk/_span_batcher.py 72.22% 13/18 covered; missed: 96, 106, 115, 118, 119; partial branches: 95, 105
sentry_sdk/_batcher.py 50.00% 1/2 covered; missed: 113
Coverage diff
@@            Coverage Diff             @@
##        master     #8325       +/-##
==========================================
+ Coverage    90.11%    90.13%    +0.02%
==========================================
  Files          201       201         —
  Tracked lines     22199     22264       +65
  Branches      7784      7796       +12
==========================================
+ Hits         20004     20067       +63
- Misses        2195      2197        +2
- Partials      1283      1290        +7

Generated by Coverage Action

@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

@sentrivana sentrivana left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I didn't check line-by-line but I assume there are no actual changes in the code, it was just moved? If that's not the case lmk and I'll take a closer look

Comment thread sentry_sdk/_batcher.py
with capture_internal_exceptions():
self._flush()

def add(self, item: "T") -> None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would be good to leave a stub for add() here so that the base class advertises it as part of the batcher "protocol"

@alexander-alderman-webb

Copy link
Copy Markdown
Collaborator Author

Yes the code was just copied into the subclasses, there shouldn't be any behavior change.

@sentrivana

Copy link
Copy Markdown
Collaborator

Why do this in the first place? 👀 I just had a look at the other PRs. I'd thought you wanted to use the new base class in them, but it looks like the new metrics batcher doesn't inherit from Batcher at all?

@alexander-alderman-webb

Copy link
Copy Markdown
Collaborator Author

Good shout, I did it without inheritance at first to make iterating easier, and forgot to wire the superclass in 😞.
I'll update the follow ups now 👍

Base automatically changed from major/3.0 to master November 23, 2026 08:56
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 5dee353.

Main concerns: reach, host performance, data sent to Sentry.

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

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