Skip to content

ref(o11y): Support sentry-sdk configured with the streaming trace lifecycle - #767

Merged
victoria-yining-huang merged 2 commits into
mainfrom
webb/streaming-trace-lifecycle-2
Jul 29, 2026
Merged

ref(o11y): Support sentry-sdk configured with the streaming trace lifecycle#767
victoria-yining-huang merged 2 commits into
mainfrom
webb/streaming-trace-lifecycle-2

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Use the sentry_sdk.traces API when the streaming lifecycle is enabled.
The previous API is a no-op when the lifecycle is enabled.

This PR consists of:

  • cherry-picking 3db8d2d
  • an early return of nullcontext() when start_span() is called without an active span to become the parent. See d6885e4

We saw a large increase segment spans in the previous dogfooding attempt. The majority of the increased span volume consisted of spans with op queue.publish and the name sentry.spans.process_segments.process_segment. These new spans are segment spans and were previously dropped as the existing start_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.

…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.
@alexander-alderman-webb
alexander-alderman-webb requested a review from a team as a code owner July 27, 2026 17:44
transaction.set_data(
"taskworker-task", {"args": args, "kwargs": kwargs, "id": activation.id}
)
# Do not attach on StreamedSpan because eager serialization increases memory use.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

More because I'm curious - how significant is the increase in memory due to the eager serialization?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Context is here: #757 (comment)

Comment on lines +49 to +51
if span is None:
return nullcontext()
return span

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 🤷

Comment thread clients/python/src/taskbroker_client/sdk.py
@victoria-yining-huang
victoria-yining-huang merged commit 239587a into main Jul 29, 2026
29 checks passed
@victoria-yining-huang
victoria-yining-huang deleted the webb/streaming-trace-lifecycle-2 branch July 29, 2026 22:03
@cleptric cleptric changed the title ref(o11y): Support sentry-sdk configured with the streaming trace lifecycle (#757) ref(o11y): Support sentry-sdk configured with the streaming trace lifecycle Jul 30, 2026
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.

4 participants