-
Notifications
You must be signed in to change notification settings - Fork 175
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
tracing: Only decode the traceparent and tracestate headers #1021
Conversation
We all change the UnicodeDecodeError exception to be a debug message. This really shouldn't happen oncee we are restricting the headers to tracestate and traceparent though.
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.
thanks Trevor!
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.
lgtm other than test failures
key = k.decode() | ||
if key == "traceparent" or key == "tracestate": |
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.
Just checking, are we sure these are always lowercase? I would expect them to be since WSGI normalizes header capitalization but probably worth checking.
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.
They should only be being set by the otel lib at this point and the spec is lowercase. I think we should be good.
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.
But maybe we should just do a non case-sensitive test now that we have the old trace headers.
header_dict[k.decode()] = v.decode() | ||
# this is only for w3c trace headers | ||
key = k.decode() | ||
if key in ["traceparent", "tracestate", "Trace", "Span", "Sampled", "Flags"]: |
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.
can we move this slightly magic array to a set somewhere?
W3C_HEADERS = {...} ?
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.
+1, maybe W3C_HEADERS = frozenset((...))
as a general best practice so it's not mutable.
18c9856
to
99dca60
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.
also slightly smaller perf impact from only decoding relevant headers. i like it.
We all change the UnicodeDecodeError exception to be a debug message. This really shouldn't happen oncee we are restricting the headers to tracestate and traceparent though.