Skip to content

Commit 6795295

Browse files
Fix trace context in event payload (#2205)
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 <ivana.kellyerova@sentry.io>
1 parent d26e4a9 commit 6795295

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sentry_sdk/scope.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,11 +605,11 @@ def _drop(cause, ty):
605605

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

608-
if has_tracing_enabled(options):
609-
if self._span is not None:
608+
if contexts.get("trace") is None:
609+
if has_tracing_enabled(options) and self._span is not None:
610610
contexts["trace"] = self._span.get_trace_context()
611-
else:
612-
contexts["trace"] = self.get_trace_context()
611+
else:
612+
contexts["trace"] = self.get_trace_context()
613613

614614
exc_info = hint.get("exc_info")
615615
if exc_info is not None:

0 commit comments

Comments
 (0)