Skip to content

ref: Flush trace bucket when segment span finishes - #7170

Draft
alexander-alderman-webb wants to merge 7 commits into
webb/batcher/remove-global-limitsfrom
webb/flush-segment-buckets
Draft

ref: Flush trace bucket when segment span finishes#7170
alexander-alderman-webb wants to merge 7 commits into
webb/batcher/remove-global-limitsfrom
webb/flush-segment-buckets

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

Mark the corresponding bucket as pending in the span buffer when a segment span is added.

This aims to keep memory pressure low. Segment spans typically finish after their children. There may be multiple segments in a trace, and flushing more frequently leads to more outbound network requests in these cases.

Adapt span batcher tests by adding an outer segment in most tests. As a result, the various flush conditions are still exercised as the assertions run before the segment span has finished (finishing the segment span otherwise flushes the buffer as well).

The tests that exercise multiple buckets are changed to use traces.new_trace() in combination with a segment span that's left open

Issues

Reminders

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

102528 passed | ❌ 2 failed | ⏭️ 6677 skipped | Total: 109207 | Pass Rate: 93.88% | Execution Time: 358m 50s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -1872
Passed Tests 📉 -1874
Failed Tests 📈 +2
Skipped Tests

➕ New Tests (1)

View new tests
  • test_binary_content_encoding_image_url[False-False]
    • File: tests.integrations.litellm.test_litellm
    • Status: ❌ Failing

❌ Failed Tests

test_binary_content_encoding_image_url[False-False]

File: tests.integrations.litellm.test_litellm
Suite: py3.10-litellm-v1.96.0
Error: assert 0 == 1 + where 0 = len([])

Stack Trace
tests/integrations/litellm/test_litellm.py:2875: in test_binary_content_encoding_image_url
    assert len(chat_spans) == 1
E   assert 0 == 1
E    +  where 0 = len([])

✅ Patch coverage is 100.00%. Project has 2477 uncovered lines.
✅ Project coverage is 90.15%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    90.14%    90.15%    +0.01%
==========================================
  Files          193       193         —
  Lines        25183     25138       -45
  Branches      9176      9138       -38
==========================================
+ Hits         22700     22661       -39
- Misses        2483      2477        -6
- Partials      1429      1432        +3

Generated by Codecov Action

@alexander-alderman-webb
alexander-alderman-webb marked this pull request as ready for review August 11, 2026 14:46
@alexander-alderman-webb
alexander-alderman-webb requested a review from a team as a code owner August 11, 2026 14:46

@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 and found 1 potential issue.

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 b3da36f. Configure here.

Comment thread sentry_sdk/_span_batcher.py Outdated
Comment thread sentry_sdk/_span_batcher.py Outdated
@alexander-alderman-webb
alexander-alderman-webb marked this pull request as draft August 11, 2026 15:08
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.

1 participant