-
Notifications
You must be signed in to change notification settings - Fork 30
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
fix: multiple server-tracing headers aren't handled #1077
fix: multiple server-tracing headers aren't handled #1077
Conversation
.addHeader("Server-Timing", "othervalue 1") | ||
.addHeader("Server-Timing", "traceparent;desc=\"00-9499195c502eb217c448a68bfe0f967c-fe16eca542cd5d86-01\"") | ||
.addHeader("Server-Timing", "othervalue 2") |
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.
Do we know the circumstances that would cause this to happen? Seems a little strange, but doesn't violate the http spec, so I suppose the server side can do all kinds of odd things.
I think the test should should be enhanced to cover the case were there are 2+ Server-Timing
headers, both of which are parseable but with different values. The logic currently reads like the last one "wins" .... is this intentional? If so, let's assert that intention with test coverage. 👍🏻 Thanks!
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.
Thank you @breedx-splk for your help.
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.
CDN in the customer's account is adding its own Server-Timing
. They have their own prefix instead of traceparent
, so we can distinguish them.
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.
In most header-emission apis, it is much easier to simply add a single header line than to find an existing one with the same key and then modify or upsert it. So, yes, this is probably going to happen. Likewise, header receipt apis differ in the guarantees they make in terms of how they present this situation (as a unified comma-separated list, as an array of values from a key, etc.). So, I think the client side of this should
- search exhaustively for a
Server-Timing
metric namedtraceparent
(across comma-separate values, across multiple header lines), but - make no guarantees about which one will be used if multiple (validly formed)
traceparent
s are present (just do whatever is easier given the api surface we have at hand).
An alternative would be to add all found valid values as links, but that would require using actual otel span links (which do not require unique names and can have identical attribute keys/values) instead of our current link.*
attribute pair. I'd consider that a future goal.
Thank you @jtmalinowski! |
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.
Approving this as the solution looks good to me, other than the open question above - if there are multiple valid headers, how should that be handled. Thanks!
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.
Alright, looking good. Thanks thanks!
@jtmalinowski Please do a similar PR against the 1.7.x branch as well. |
|
||
assertThat(attributes).containsOnly(entry(COMPONENT_KEY, "http")); | ||
private Response.Builder getBaseRuestBuilder(Request fakeRequest) { |
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.
nit: missed 'q' in request -> getBaseRuestBuilder
When multiple
server-tracing
headers are present, handle all of them. Previously only the first instance would be handled.