Skip to content

Commit b89fa8d

Browse files
authored
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
1 parent 684c43f commit b89fa8d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

sentry_sdk/tracing.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,18 @@ def new_span(self, **kwargs):
804804
# type: (**Any) -> NoOpSpan
805805
return self.start_child(**kwargs)
806806

807+
def to_traceparent(self):
808+
# type: () -> str
809+
return ""
810+
811+
def to_baggage(self):
812+
# type: () -> Optional[Baggage]
813+
return None
814+
815+
def iter_headers(self):
816+
# type: () -> Iterator[Tuple[str, str]]
817+
return iter(())
818+
807819
def set_tag(self, key, value):
808820
# type: (str, Any) -> None
809821
pass
@@ -820,6 +832,18 @@ def set_http_status(self, http_status):
820832
# type: (int) -> None
821833
pass
822834

835+
def is_success(self):
836+
# type: () -> bool
837+
return True
838+
839+
def to_json(self):
840+
# type: () -> Dict[str, Any]
841+
return {}
842+
843+
def get_trace_context(self):
844+
# type: () -> Any
845+
return {}
846+
823847
def finish(self, hub=None, end_timestamp=None):
824848
# type: (Optional[sentry_sdk.Hub], Optional[datetime]) -> Optional[str]
825849
pass

0 commit comments

Comments
 (0)