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

W3CBaggagePropagator lowercasing keys #3146

Closed
mrduncan opened this issue Jan 26, 2023 · 1 comment · Fixed by #3151
Closed

W3CBaggagePropagator lowercasing keys #3146

mrduncan opened this issue Jan 26, 2023 · 1 comment · Fixed by #3151
Labels
api Affects the API package. bug Something isn't working good first issue Good first issue help wanted

Comments

@mrduncan
Copy link

opentelemetry.baggage.propagation.W3CBaggagePropagator is lowercasing keys in extract, as far as I can tell the W2C baggage spec does not define this behavior.

I also confirmed the go implementation does not lowercase keys: https://go.dev/play/p/9H4HKKmSRMA

I think just removing the .lower() here should fix it: https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-api/src/opentelemetry/baggage/propagation/__init__.py#L96

Steps to reproduce

from opentelemetry import baggage
from opentelemetry.baggage.propagation import W3CBaggagePropagator

carrier = {}
propagator = W3CBaggagePropagator()

ctx = baggage.set_baggage('userId', '1')
print(ctx)

propagator.inject(carrier, ctx)
print(carrier)

print(propagator.extract(carrier))

What is the expected behavior?

{'baggage-ce2af44a-cf4d-4151-88a5-349b34d2c353': {'userId': '1'}}
{'baggage': 'userId=1'}
{'baggage-ce2af44a-cf4d-4151-88a5-349b34d2c353': {'userId': '1'}}

What is the actual behavior?

{'baggage-ce2af44a-cf4d-4151-88a5-349b34d2c353': {'userId': '1'}}
{'baggage': 'userId=1'}
{'baggage-ce2af44a-cf4d-4151-88a5-349b34d2c353': {'userid': '1'}} # note lowercased key
@mrduncan mrduncan added the bug Something isn't working label Jan 26, 2023
@srikanthccv
Copy link
Member

Feel free to send a pull request

@srikanthccv srikanthccv added good first issue Good first issue help wanted api Affects the API package. labels Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Affects the API package. bug Something isn't working good first issue Good first issue help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants