ref(o11y): Support sentry-sdk configured with the streaming trace lifecycle - #767
Merged
Merged
Conversation
…ifecycle (#757) Use the `sentry_sdk.traces` API when the streaming lifecycle is enabled. The previous API is a no-op when the lifecycle is enabled.
ericapisani
reviewed
Jul 28, 2026
| transaction.set_data( | ||
| "taskworker-task", {"args": args, "kwargs": kwargs, "id": activation.id} | ||
| ) | ||
| # Do not attach on StreamedSpan because eager serialization increases memory use. |
Member
There was a problem hiding this comment.
More because I'm curious - how significant is the increase in memory due to the eager serialization?
Comment on lines
+49
to
+51
| if span is None: | ||
| return nullcontext() | ||
| return span |
Member
There was a problem hiding this comment.
Looking at this method and the start_span method below - I don't fully understand what types of exceptions we're guarding against (and from where, the streamed span or transaction logic) that we need this null context.
Could you provide some more context on why we need the try/except above along with this fallback?
Contributor
Author
There was a problem hiding this comment.
We used a shim without the try...except in sentry itself. There's nothing in particular that I'd expect to blow up. We could also get rid of the try...except 🤷
evanh
approved these changes
Jul 28, 2026
3 tasks
sentry-sdk configured with the streaming trace lifecycle (#757)sentry-sdk configured with the streaming trace lifecycle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use the
sentry_sdk.tracesAPI when the streaming lifecycle is enabled.The previous API is a no-op when the lifecycle is enabled.
This PR consists of:
nullcontext()whenstart_span()is called without an active span to become the parent. See d6885e4We saw a large increase segment spans in the previous dogfooding attempt. The majority of the increased span volume consisted of spans with op
queue.publishand the namesentry.spans.process_segments.process_segment. These new spans are segment spans and were previously dropped as the existingstart_span()API is a no-op when there is no transaction.The early return is added to keep span volume constant when switching the trace lifecycle while using
taskbroker.