From b89fa8d9a7874ab309d381251ef744ed35057c6a Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Tue, 11 Jul 2023 10:35:22 +0200 Subject: [PATCH] Prevent adding `sentry-trace` header multiple times (#2235) If OpenTelementry is enabled, the sentry-trace headers should not be applied by Sentry intregration, but only by the OTel propagator. Fixes #1940 --- sentry_sdk/tracing.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sentry_sdk/tracing.py b/sentry_sdk/tracing.py index 8e642f296a..fa65e49fbe 100644 --- a/sentry_sdk/tracing.py +++ b/sentry_sdk/tracing.py @@ -804,6 +804,18 @@ def new_span(self, **kwargs): # type: (**Any) -> NoOpSpan return self.start_child(**kwargs) + def to_traceparent(self): + # type: () -> str + return "" + + def to_baggage(self): + # type: () -> Optional[Baggage] + return None + + def iter_headers(self): + # type: () -> Iterator[Tuple[str, str]] + return iter(()) + def set_tag(self, key, value): # type: (str, Any) -> None pass @@ -820,6 +832,18 @@ def set_http_status(self, http_status): # type: (int) -> None pass + def is_success(self): + # type: () -> bool + return True + + def to_json(self): + # type: () -> Dict[str, Any] + return {} + + def get_trace_context(self): + # type: () -> Any + return {} + def finish(self, hub=None, end_timestamp=None): # type: (Optional[sentry_sdk.Hub], Optional[datetime]) -> Optional[str] pass