-
Notifications
You must be signed in to change notification settings - Fork 230
Implement Trace Context standard #660
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
Conversation
… header On incoming requests, we first check for the presence of `traceparent`, and fall back to `elastic-apm-traceparent`. For outgoing requests, `traceparent` is always set. `elastic-apm-traceparent` is set if the config option `use_elastic_traceparent_header` is set to True. For now, this option defaults to True, but will be changed to False after a grace period.
Initially, we only forward the header, and don't try to parse its content. This will only be necessary once we start adding our own data to tracestate
c704bff
to
feacdbf
Compare
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.
Great work! Love the thorough testing. As far as I can tell we've hit the spec exactly.
@classmethod | ||
def merge_duplicate_headers(cls, headers, key): | ||
""" | ||
HTTP allows multiple values for the same header name. Most WSGI implementations | ||
merge these values using a comma as separator (this has been confirmed for wsgiref, | ||
werkzeug, gunicorn and uwsgi). Other implementations may use containers like | ||
multidict to store headers and have APIs to iterate over all values for a given key. | ||
This method is provided as a hook for framework integrations to provide their own | ||
TraceParent implementation. The implementation should return a single string. Multiple | ||
values for the same key should be merged using a comma as separator. | ||
:param headers: a dict-like header object | ||
:param key: header name | ||
:return: a single string value | ||
""" | ||
# this works for all known WSGI implementations | ||
return headers.get(key) |
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.
Good work being so thorough with your investigation here. And for providing something to override if Murphy's Law gives us a WSGI implementation with different behavior.
7c30e18
to
c6eaa57
Compare
traceparent
headertracestate
header propagationWhat does this pull request do?
On incoming requests, we first check for the presence of
traceparent
,and fall back to
elastic-apm-traceparent
.For outgoing requests,
traceparent
is always set.elastic-apm-traceparent
is set if the config option
use_elastic_traceparent_header
is set toTrue. For now, this option defaults to True, but will be changed to False
after a grace period.
Why is it important?
TraceContext is now a recommendation candidate, time to support it
fully.
Related issues
closes #628
refs elastic/apm#71