Skip to content

chore: Inline span-streaming branch of tracing shims in replays - #124720

Merged
alexander-alderman-webb merged 3 commits into
masterfrom
webb/replays/remove-tracing-shim
Oct 12, 2026
Merged

alexander-alderman-webb merged 3 commits into
masterfrom
webb/replays/remove-tracing-shim

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Inline the branches of utils.tracing.start_span(), utils.tracing.trace(), utils.tracing.set_span_tag() and utils.tracing.set_span_data() that run when the streaming trace lifecycle is enabled.

Since edfb641 the streaming trace lifecycle is always enabled.

Add repr() around the second argument to StreamedSpan.set_attribute() when mypy complains. Calling repr() is the existing runtime fallback in the SDK.

Set attributes in the attributes parameter to traces.start_span() instead of calling StreamedSpan.set_attribute() where reasonable.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 17, 2026
@alexander-alderman-webb
alexander-alderman-webb force-pushed the webb/replays/remove-tracing-shim branch from e78e9bd to f90af46 Compare September 22, 2026 11:28
@alexander-alderman-webb
alexander-alderman-webb marked this pull request as ready for review September 22, 2026 11:28
@alexander-alderman-webb
alexander-alderman-webb requested a review from a team September 22, 2026 11:28
Comment on lines +163 to +186
traces.new_trace()
span = None
if self.sample_rate_get:
active_propagation_context = (
sentry_sdk.get_current_scope().get_active_propagation_context()
)
prev_sampling_context = active_propagation_context.custom_sampling_context
Scope.set_custom_sampling_context({"sample_rate": self.sample_rate_get})
try:
span = traces.start_span(
name="replays.endpoints.project_replay_summary.get",
attributes={"sentry.op": "replays.endpoints.project_replay_summary.get"},
parent_span=None,
)
finally:
active_propagation_context.custom_sampling_context = prev_sampling_context
if span is None:
span = traces.start_span(
name="replays.endpoints.project_replay_summary.get",
attributes={"sentry.op": "replays.endpoints.project_replay_summary.get"},
parent_span=None,
)

with 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.

Might be worth to keep some wrapper for this. Also present in other PRs, but this one is a lot of boilerplate.

@alexander-alderman-webb
alexander-alderman-webb merged commit 706a7f0 into master Oct 12, 2026
73 checks passed
@alexander-alderman-webb
alexander-alderman-webb deleted the webb/replays/remove-tracing-shim branch October 12, 2026 10:25

This branch was successfully deployed

1 active deployment
Preview — 58d59181 Deployed Oct 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants