Skip to content

Commit

Permalink
Fix trace context in event payload (#2205)
Browse files Browse the repository at this point in the history
Make sure that always a trace context is added to the event payload. But also make sure that if there is already a trace context in the event, do not overwrite it. (This used to be the behavior before tracing without performance. See: https://github.com/getsentry/sentry-python/blob/1.25.1/sentry_sdk/scope.py#L420)

---------

Co-authored-by: Ivana Kellyerova <[email protected]>
  • Loading branch information
antonpirker and sentrivana authored Jun 28, 2023
1 parent d26e4a9 commit 6795295
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,11 @@ def _drop(cause, ty):

contexts = event.setdefault("contexts", {})

if has_tracing_enabled(options):
if self._span is not None:
if contexts.get("trace") is None:
if has_tracing_enabled(options) and self._span is not None:
contexts["trace"] = self._span.get_trace_context()
else:
contexts["trace"] = self.get_trace_context()
else:
contexts["trace"] = self.get_trace_context()

exc_info = hint.get("exc_info")
if exc_info is not None:
Expand Down

0 comments on commit 6795295

Please sign in to comment.