Skip to content

chore: Move locks into batcher subclasses - #8325

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

alexander-alderman-webb wants to merge 4 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 📊

✅ 59241 passed | ⏭️ 3047 skipped | Total: 62288 | Pass Rate: 95.11% | Execution Time: 176m 50s

📊 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.05% (down 0.06 percentage points from base (3069315) to head (f5bcbf4)).

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.05%    -0.06%
==========================================
  Files          200       200         —
  Tracked lines     22098     22178       +80
  Branches      7746      7770       +24
==========================================
+ Hits         19913     19971       +58
- Misses        2185      2207       +22
- Partials      1277      1282        +5

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

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants