-
Notifications
You must be signed in to change notification settings - Fork 571
Simplify continue_trace to reuse propagation_context values #5158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1186,28 +1186,26 @@ def continue_trace( | |
| """ | ||
| self.generate_propagation_context(environ_or_headers) | ||
|
|
||
| # When we generate the propagation context, the sample_rand value is set | ||
| # if missing or invalid (we use the original value if it's valid). | ||
| # We want the transaction to use the same sample_rand value. Due to duplicated | ||
| # propagation logic in the transaction, we pass it in to avoid recomputing it | ||
| # in the transaction. | ||
| # TYPE SAFETY: self.generate_propagation_context() ensures that self._propagation_context | ||
| # is not None. | ||
| sample_rand = typing.cast( | ||
| PropagationContext, self._propagation_context | ||
| )._sample_rand() | ||
|
|
||
| transaction = Transaction.continue_from_headers( | ||
| normalize_incoming_data(environ_or_headers), | ||
| _sample_rand=sample_rand, | ||
| # generate_propagation_context ensures that the propagation_context is not None. | ||
| propagation_context = typing.cast(PropagationContext, self._propagation_context) | ||
|
|
||
| optional_kwargs = {} | ||
| if name: | ||
| optional_kwargs["name"] = name | ||
| if source: | ||
| optional_kwargs["source"] = source | ||
|
|
||
| return Transaction( | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. annoyingly, the type signature of |
||
| op=op, | ||
| origin=origin, | ||
| name=name, | ||
| source=source, | ||
| baggage=propagation_context.baggage, | ||
| parent_sampled=propagation_context.parent_sampled, | ||
| trace_id=propagation_context.trace_id, | ||
| parent_span_id=propagation_context.parent_span_id, | ||
| same_process_as_parent=False, | ||
| **optional_kwargs, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Missing baggage freeze loses third-party baggage itemsWhen continuing a trace, the old code explicitly called
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we actually only call |
||
| ) | ||
|
Comment on lines
+1197
to
1207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The new 🔍 Detailed AnalysisWhen an incoming 💡 Suggested FixIf 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is because we froze the DSC earlier in the transaction but not in the propagation context, I will fix this separately tomorrow. Also in some SDKs, we have given up freezing completely so maybe I'll just leave it out. |
||
|
|
||
| return transaction | ||
|
|
||
| def capture_event(self, event, hint=None, scope=None, **scope_kwargs): | ||
| # type: (Event, Optional[Hint], Optional[Scope], Any) -> Optional[str] | ||
| """ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we already remove the
_sample_randarg and associated logic fromcontinue_from_headersaltogether or is that still used anywhere?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will remove, technically breaking but it's an underscore so finenvm, let's do all this in the major, we will remove
continue_from_headersitself.