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

XCloudTraceContextPropagator assumes lowercase header #365

Closed
mackenziestarr opened this issue Aug 29, 2024 · 8 comments
Closed

XCloudTraceContextPropagator assumes lowercase header #365

mackenziestarr opened this issue Aug 29, 2024 · 8 comments
Assignees
Labels
bug Something isn't working priority: p2

Comments

@mackenziestarr
Copy link

XCloudTraceContextPropagator assumes the carrier parameter contains a lowercase header x-cloud-trace-context and as a result other valid capitalization styles of this header e.g. X-Cloud-Trace-Context are not extracted. This constraint makes the propagator class less flexible and I think there is benefit to allowing other common capitalizations of the header.

// TODO - Do we need to iterate over keys and lowercase them, or is java doing that for us?
String value = getter.get(carrier, FIELD);

Proposed fix: support X-Cloud-Trace-Context in addition to the currently supported x-cloud-trace-context

  • when injecting the context, write both keys to the carrier
  • when extracting the context, lookup both keys in the carrier

this fix seems ideal from a performance perspective (vs. the suggested iterating over the keys and lowercasing them) but might have other implications

@dashpole
Copy link
Contributor

dashpole commented Sep 4, 2024

Triage: IIRC, we do this for other languages, so we probably should here as well.

@dashpole dashpole added bug Something isn't working priority: p2 labels Sep 4, 2024
@dashpole
Copy link
Contributor

dashpole commented Sep 4, 2024

I would have expected the carrier (e.g. http header implementation) to handle this. We should check that first.

@mackenziestarr what were you trying to do when you encountered this? Was it with OTel's HTTP library, or something else?

@mackenziestarr
Copy link
Author

@dashpole in this case I'm integrating OTel into a thrift server that utilized a TCP transport so the "header" is passed in via a map<string, string> context field in the thrift request message - I can also change the clients to send a lowercase version and close this issue but i thought wider compatibility for different header capitalization styles might be desirable still because of the TODO in the source.

@psx95
Copy link
Contributor

psx95 commented Sep 20, 2024

Hi @mackenziestarr,

I looked into this and I think the TODO comment should have been removed/updated. It is from a very old commit and I think spec might have changed since then - I searched around and found that the current spec around Get method mentions that implementation of Get function is responsible for handling case sensitivity.

Since we don't provide an implementation for TextMapGetter, I do not think this lowercasing should be addressed in these propagators. The users using this propagators should provide for an appropriate implementation for the getter method. For instance, we use the propagators in our e2e-tests and we provide a TextMapGetter implementation that deals with case-sensitivity.

Let me know if my interpretation of the spec makes sense to you.

@dashpole
Copy link
Contributor

@psx95 should we open an issue upstream?

@psx95
Copy link
Contributor

psx95 commented Sep 22, 2024

@dashpole an issue to update the propagators API spec or to somehow provide commonly used getters ?

@dashpole
Copy link
Contributor

Sorry, I had forgotten context from #365 (comment). @mackenziestarr when you implement your TextMapGetter, that is where the lowercasing should happen.

@psx95 you can close the issue once you've removed the comment.

@mackenziestarr
Copy link
Author

@psx95 thanks the explanations and links to the spec, it wasn't very intuitive to me that one would need to iterate over entries in the map to test for the header key provided by XCloudTraceContextPropagator.

i was hoping for an API that provided a default implementation of a TextMapGetter for Map so one could just call it like

Map<String, ?> input;
var context = new XCloudTraceContextPropagator(true).extract(Context.current(), input)

but understand if that is too specific to my own implementation

thanks for your time here @psx95 and @dashpole, we can call this closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: p2
Projects
None yet
Development

No branches or pull requests

3 participants