ref(batcher): Only flush the bucket that triggered the flush event#6168
ref(batcher): Only flush the bucket that triggered the flush event#6168sentrivana wants to merge 23 commits intomasterfrom
Conversation
Codecov Results 📊✅ 13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 8.04s All tests are passing successfully. ✅ Patch coverage is 85.71%. Project has 14946 uncovered lines. Files with missing lines (1)
Generated by Codecov Action |
| assert get_profiler_id() is None, "profiler should have stopped" | ||
|
|
||
|
|
||
| def test_transport_format(sentry_init, capture_envelopes): |
There was a problem hiding this comment.
This one was split in two (test_default_attributes and test_transport_format) and the latter was moved to test_span_buffer
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2b37852. Configure here.
alexander-alderman-webb
left a comment
There was a problem hiding this comment.
LGTM!
It's probably not great having so many sleeps in the test, but the alternative is relying on private details (which wouldn't be good either).
Yeah definitely. Tried to keep them as low as possible at least. |

Description
The span batcher uses multiple buffers (buckets) to store spans, keyed by
trace_id. If a bucket fills up, we flush the whole buffer (all the buckets) instead of just the one bucket that actually should be flushed. This leads to too-frequent, busy flushes and is also against the spec.With this change, we keep a set of buckets to flush. We still support full flushes for cases when
sentry_sdk.flush()is called manually, or when the SDK is shutting down. Time-based flushes are also still global, i.e., not per bucket.Issues
Reminders
tox -e linters.feat:,fix:,ref:,meta:)