Skip to content
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

Merged
merged 4 commits into from
Nov 12, 2024

Conversation

trevorriles
Copy link
Contributor

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.

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.
Copy link
Contributor

@salomon-smekecohen salomon-smekecohen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Trevor!

Copy link
Member

@chriskuehl chriskuehl left a 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

Comment on lines 86 to 87
key = k.decode()
if key == "traceparent" or key == "tracestate":
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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"]:
Copy link
Contributor

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 = {...} ?

Copy link
Member

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.

Copy link
Contributor

@salomon-smekecohen salomon-smekecohen left a 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.

@chriskuehl chriskuehl merged commit 6f4d891 into develop Nov 12, 2024
4 checks passed
@chriskuehl chriskuehl deleted the push-swukuupqynll branch November 12, 2024 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants