-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(propagation): add DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT to handle x-org propagation #11631
base: main
Are you sure you want to change the base?
Changes from 13 commits
75e962b
6bb2036
9924f37
e1b10df
6811970
8ce6f80
ffd8fe2
34190b1
290d9e6
87532da
b32a467
837e213
97554cd
4436896
4dee1de
57b3239
a0b2c34
cf57ae8
83498fa
d5293e0
af2c94f
37117d2
5a40b91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -560,14 +560,12 @@ def activate_distributed_headers(tracer, int_config=None, request_headers=None, | |
""" | ||
if override is False: | ||
return None | ||
ZStriker19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if override or (int_config and distributed_tracing_enabled(int_config)): | ||
context = HTTPPropagator.extract(request_headers) | ||
|
||
# Only need to activate the new context if something was propagated | ||
if not context.trace_id: | ||
if not context.trace_id and not context._baggage: | ||
return None | ||
|
||
# Do not reactivate a context with the same trace id | ||
# DEV: An example could be nested web frameworks, when one layer already | ||
# parsed request headers and activated them. | ||
|
@@ -577,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 == context.trace_id: | ||
|
||
# We accept incoming contexts with only baggage, however if we | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We accept contexts lacking trace_id to cover the following cases:
Unfortunately we can't compare baggages to tell if they're the same as the original headers, since the original incoming baggage could've been modified before we try to activate new headers in a nested framework. However, an alternative to tossing out an incoming baggage after we have an active context would be to merge them in some way, however I think that this is worse since it's possible customers may want to delete items from baggage. I think the same applies to how span links could be modified as well. |
||
# 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, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
features: | ||
- | | ||
propagation: This introduces the environment variable ``DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT`` | ||
to control the behavior of the extraction of distributed tracing headers. The values, ``continue`` (default), | ||
``ignore``, and ``restart``, are supported. The default value is ``continue`` which should have no change from the current behavior of always propagating valid headers. | ||
With ``ignore`` ignoring all incoming headers and with ``restart`` turning incoming headers into a span links and propagating baggage items. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to remove these, just doing because struggling to build tracer locally