Skip to content

ref: Add streaming trace decorator (7)#5594

Open
sentrivana wants to merge 8 commits intoivana/span-first-6-add-continue-and-new-tracefrom
ivana/span-first-7-add-trace-decorator
Open

ref: Add streaming trace decorator (7)#5594
sentrivana wants to merge 8 commits intoivana/span-first-6-add-continue-and-new-tracefrom
ivana/span-first-7-add-trace-decorator

Conversation

@sentrivana
Copy link
Contributor

Description

Add the streaming equivalent of the @trace decorator.

Issues

Reminders

@sentrivana sentrivana force-pushed the ivana/span-first-6-add-continue-and-new-trace branch from 157d123 to 54f81af Compare March 5, 2026 13:48
@sentrivana sentrivana force-pushed the ivana/span-first-7-add-trace-decorator branch from 9a80374 to 941863e Compare March 5, 2026 13:49
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (celery) Propagate user-set headers by sentrivana in #5581

Documentation 📚

  • Add AGENTS.md by sentrivana in #5579
  • Add set_attribute example to changelog by sentrivana in #5578

Internal Changes 🔧

  • Add streaming trace decorator (7) by sentrivana in #5594

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Codecov Results 📊

13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 7.01s

All tests are passing successfully.

❌ Patch coverage is 17.50%. Project has 13855 uncovered lines.

Files with missing lines (2)
File Patch % Lines
tracing_utils.py 43.69% ⚠️ 348 Missing and 28 partials
traces.py 51.70% ⚠️ 71 Missing

Generated by Codecov Action

@sentrivana sentrivana marked this pull request as ready for review March 5, 2026 14:58
@sentrivana sentrivana requested a review from a team as a code owner March 5, 2026 14:58
Copy link

@cursor cursor bot left a comment

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.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

def __exit__(
self, ty: "Optional[Any]", value: "Optional[Any]", tb: "Optional[Any]"
) -> None:
pass
Copy link

Choose a reason for hiding this comment

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

Context manager __enter__ doesn't register span as active

Medium Severity

StreamedSpan.__enter__ just returns self without setting the span as the active span on the scope. The existing Span.__enter__ in tracing.py does scope.span = self so that nested spans can discover their parent. Without this, create_streaming_span_decorator's with start_streaming_span(...) never makes the span visible to the scope, so nested @trace-decorated functions each create independent root spans instead of forming a parent-child tree. The corresponding __exit__ also doesn't restore the previous span or set error status on exceptions, unlike the analogous Span.__exit__.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants