Skip to content

Conversation

@sl0thentr0py
Copy link
Member

@sl0thentr0py sl0thentr0py commented Dec 2, 2025

Description

When there is any sort of incoming data, and since continue_trace is always intended to be at a system boundary, we always want to force a new trace if there's no incoming propagation or a mismatched propagation headers (for strict_trace_continuation).

What previously happened in these cases: a single trace_id was kept alive in the propagation_context even when these were meant to be new independent traces (see screenshot that shows undesired behavior before this fix).

I think this will actually solve many complaints about long living traces that were never supposed to be such.

image

self._propagation_context = propagation_context
self._propagation_context = PropagationContext.from_incoming_data(incoming_data)

# TODO-neel this below is a BIG code smell but requires a bunch of other refactoring
Copy link
Member Author

Choose a reason for hiding this comment

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

@alexander-alderman-webb since you wanted me to point out more insights like these, this branch and how it interacts with the get_active_propagation_context method logic is still pretty badly implemented.

@sl0thentr0py sl0thentr0py force-pushed the neel/prop-context-incoming-data branch from ad10877 to 3f4dfd4 Compare December 2, 2025 13:43
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.98%. Comparing base (9c9510d) to head (5dae95a).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5186      +/-   ##
==========================================
+ Coverage   83.94%   83.98%   +0.03%     
==========================================
  Files         181      181              
  Lines       18419    18417       -2     
  Branches     3281     3280       -1     
==========================================
+ Hits        15462    15467       +5     
+ Misses       1944     1938       -6     
+ Partials     1013     1012       -1     
Files with missing lines Coverage Δ
sentry_sdk/scope.py 88.36% <100.00%> (-0.04%) ⬇️
sentry_sdk/tracing_utils.py 86.29% <100.00%> (-0.36%) ⬇️

... and 4 files with indirect coverage changes

@sl0thentr0py sl0thentr0py force-pushed the neel/prop-context-incoming-data branch from 3f4dfd4 to fe6cb05 Compare December 2, 2025 13:59
…nContext

When there is any sort of incoming data, and since `continue_trace` is
always intended to be at a system boundary, we always want to force a
new trace if there's no incoming propagation or an incorrect propagation
header.

What previously happened is in these cases, a single `trace_id` was kept
alive in the `propagation_context` even when these were just meant to be
new independent traces (see screenshot).

I think this will actually solve many complaints about long living
traces that were never supposed to be such.
@sl0thentr0py sl0thentr0py force-pushed the neel/prop-context-incoming-data branch from fe6cb05 to 5dae95a Compare December 2, 2025 13:59
@sl0thentr0py sl0thentr0py changed the title Make PropagationContext.from_incoming_data always return a PropagationContext fix: Make PropagationContext.from_incoming_data always return a PropagationContext Dec 2, 2025
@sl0thentr0py sl0thentr0py marked this pull request as ready for review December 2, 2025 14:07
@sl0thentr0py sl0thentr0py requested a review from a team as a code owner December 2, 2025 14:07
Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

So do I get this right:

  • Before, if sentrytrace_data was wrong or not there we'd simply continue using the existing propagation context, meaning we'd be propagating the trace from before
  • Now, we instead create a brand new PropagationContext with new trace info

If that's the case, sounds like a much needed fix.

@sl0thentr0py
Copy link
Member Author

yep pretty much :/

@sl0thentr0py sl0thentr0py merged commit 9a9fbfe into master Dec 2, 2025
155 checks passed
@sl0thentr0py sl0thentr0py deleted the neel/prop-context-incoming-data branch December 2, 2025 14:36
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.

3 participants