From 837e2136b9e88e738e20b724de76cadbfcee17e5 Mon Sep 17 00:00:00 2001 From: ZStriker19 Date: Thu, 9 Jan 2025 13:29:56 -0500 Subject: [PATCH] fix no span on execution context error --- ddtrace/contrib/trace_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ddtrace/contrib/trace_utils.py b/ddtrace/contrib/trace_utils.py index f168f7e271..5694ff6300 100644 --- a/ddtrace/contrib/trace_utils.py +++ b/ddtrace/contrib/trace_utils.py @@ -575,7 +575,10 @@ def activate_distributed_headers(tracer, int_config=None, request_headers=None, # app = Flask(__name__) # Traced via Flask instrumentation # app = DDWSGIMiddleware(app) # Extra layer on top for WSGI current_context = tracer.current_trace_context() - if current_context and current_context.trace_id and current_context.trace_id == context.trace_id: + + # We accept incoming contexts with only baggage, however if we + # already have a current_context then a baggage only context will be tossed out + if current_context and (not context.trace_id or current_context.trace_id == context.trace_id): log.debug( "will not activate extracted Context(trace_id=%r, span_id=%r), a context with that trace id is already active", # noqa: E501 context.trace_id,