From dc579728d23d5cbf9b513c498a7945507d95c546 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Thu, 27 Jun 2024 16:05:00 +0200 Subject: [PATCH] fix(otel): Fix missing baggage (#3218) --- .../opentelemetry/span_processor.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/sentry_sdk/integrations/opentelemetry/span_processor.py b/sentry_sdk/integrations/opentelemetry/span_processor.py index 1429161c2f..dc4296d6f4 100644 --- a/sentry_sdk/integrations/opentelemetry/span_processor.py +++ b/sentry_sdk/integrations/opentelemetry/span_processor.py @@ -279,17 +279,14 @@ def _get_trace_data(self, otel_span, parent_context): ) trace_data["parent_span_id"] = parent_span_id - if parent_context is not None: - sentry_trace_data = get_value(SENTRY_TRACE_KEY, parent_context) - sentry_trace_data = cast( - "dict[str, Union[str, bool, None]]", sentry_trace_data - ) - trace_data["parent_sampled"] = ( - sentry_trace_data["parent_sampled"] if sentry_trace_data else None - ) + sentry_trace_data = get_value(SENTRY_TRACE_KEY, parent_context) + sentry_trace_data = cast("dict[str, Union[str, bool, None]]", sentry_trace_data) + trace_data["parent_sampled"] = ( + sentry_trace_data["parent_sampled"] if sentry_trace_data else None + ) - baggage = get_value(SENTRY_BAGGAGE_KEY, parent_context) - trace_data["baggage"] = baggage + baggage = get_value(SENTRY_BAGGAGE_KEY, parent_context) + trace_data["baggage"] = baggage return trace_data