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

fix: multiple server-tracing headers aren't handled #1077

Merged

Conversation

jtmalinowski
Copy link
Contributor

When multiple server-tracing headers are present, handle all of them. Previously only the first instance would be handled.

@jtmalinowski jtmalinowski requested review from a team as code owners November 20, 2024 22:26
Comment on lines 46 to 48
.addHeader("Server-Timing", "othervalue 1")
.addHeader("Server-Timing", "traceparent;desc=\"00-9499195c502eb217c448a68bfe0f967c-fe16eca542cd5d86-01\"")
.addHeader("Server-Timing", "othervalue 2")
Copy link
Contributor

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!

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.

Copy link
Contributor Author

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.

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 named traceparent (across comma-separate values, across multiple header lines), but
  • make no guarantees about which one will be used if multiple (validly formed) traceparents 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.

@aditi-s3 aditi-s3 requested a review from surbhiia November 20, 2024 22:50
@jek-bao-choo
Copy link

Thank you @jtmalinowski!

Copy link
Contributor

@surbhiia surbhiia left a 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!

Copy link
Contributor

@breedx-splk breedx-splk left a 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!

@breedx-splk breedx-splk merged commit 4b3501d into signalfx:main Nov 21, 2024
3 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2024
@breedx-splk
Copy link
Contributor

@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) {
Copy link
Contributor

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants