Skip to content

feat: Add basic lock-free metrics batcher - #8326

Open
alexander-alderman-webb wants to merge 22 commits into
webb/lock-free-basefrom
webb/sliding-window-metrics-batcher
Open

alexander-alderman-webb wants to merge 22 commits into
webb/lock-free-basefrom
webb/sliding-window-metrics-batcher

Conversation

@alexander-alderman-webb

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

Copy link
Copy Markdown
Collaborator

Description

Add a lock-free metrics batcher using a collections.deque at the core.
Consumers pop from the front of the queue, and producers add to the end of the queue.

The main trade-off is that limits are not precise anymore. The MAX_BEFORE_FLUSH limit can now be exceeded by one or more metrics per thread (conceptually, imagine all threads adding their metric simultaneously as the worst case).

There can be two consumers if sentry_sdk.flush() is called concurrently with a flush induced by reaching a limit. Consumers therefore handle IndexError.

Issues

Reminders

Loading
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