Skip to content

ref: Add experimental streaming API (5)#5592

Open
sentrivana wants to merge 17 commits intomasterfrom
ivana/span-first-5-add-start-span-api
Open

ref: Add experimental streaming API (5)#5592
sentrivana wants to merge 17 commits intomasterfrom
ivana/span-first-5-add-start-span-api

Conversation

@sentrivana
Copy link
Contributor

Description

Add sentry_sdk.traces.start_span and the corresponding scope method.

NOTE: This is experimental and not production ready code.

Issues

Reminders

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Codecov Results 📊

32 passed | Total: 32 | Pass Rate: 100% | Execution Time: 300ms

All tests are passing successfully.

❌ Patch coverage is 35.29%. Project has 15005 uncovered lines.

Files with missing lines (2)
File Patch % Lines
scope.py 63.99% ⚠️ 300 Missing and 73 partials
traces.py 54.33% ⚠️ 58 Missing

Generated by Codecov Action

@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).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@sentrivana sentrivana marked this pull request as ready for review March 5, 2026 12:37
@sentrivana sentrivana requested a review from a team as a code owner March 5, 2026 12:37
Base automatically changed from ivana/span-first-4-add-noop-span to master March 5, 2026 13:38
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 2 potential issues.

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

@sentrivana sentrivana marked this pull request as draft March 5, 2026 14:58
@sentrivana sentrivana marked this pull request as ready for review March 5, 2026 15:21
Comment on lines +1177 to +1183
def start_streamed_span(
self,
name: str,
attributes: "Optional[Attributes]" = None,
parent_span: "Optional[StreamedSpan]" = None,
active: bool = True,
) -> "StreamedSpan":
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way to explicitly create a span with is_segment=True?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is and this PR doesn't implement it correctly. Will fix.

The supported way to do that is to explicitly provide start_span(parent_span=None). The way it's implemented now in this PR, we don't distinguish between a user-set parent_span=None and the fallback value of None, which will actually try to parent the span to the currently active span. We'll need a different sentinel value for parent_span so that we can tell it apart from parent_span=None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sentrivana sentrivana marked this pull request as draft March 6, 2026 11:27
@sentrivana sentrivana marked this pull request as ready for review March 6, 2026 13:01
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb left a comment

Choose a reason for hiding this comment

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

LGTM!

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