Skip to content

W3CBaggagePropagator lowercasing keys #3146

@mrduncan

Description

@mrduncan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions