Skip to content

Commit

Permalink
cover case of only span_link
Browse files Browse the repository at this point in the history
  • Loading branch information
ZStriker19 committed Jan 9, 2025
1 parent 97554cd commit 3534533
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ddtrace/contrib/trace_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ def activate_distributed_headers(tracer, int_config=None, request_headers=None,
context = HTTPPropagator.extract(request_headers)

# Only need to activate the new context if something was propagated
if not context.trace_id and not context._baggage:
# The new context must have one of these values in order for it to be activated
if not context.trace_id and not context._baggage and not context._span_links:
return None
# Do not reactivate a context with the same trace id
# DEV: An example could be nested web frameworks, when one layer already
Expand All @@ -576,8 +577,8 @@ def activate_distributed_headers(tracer, int_config=None, request_headers=None,
# app = DDWSGIMiddleware(app) # Extra layer on top for WSGI
current_context = tracer.current_trace_context()

# We accept incoming contexts with only baggage, however if we
# already have a current_context then a baggage only context will be tossed out
# We accept incoming contexts with only baggage or only span_links, however if we
# already have a current_context then a baggage only or span_link 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
Expand Down

0 comments on commit 3534533

Please sign in to comment.