Skip to content

Strip only the leading uberctx- prefix from a Jaeger baggage key - #5557

Open
serhiy-bzhezytskyy wants to merge 3 commits into
open-telemetry:mainfrom
serhiy-bzhezytskyy:fix/jaeger-baggage-key-prefix
Open

Strip only the leading uberctx- prefix from a Jaeger baggage key#5557
serhiy-bzhezytskyy wants to merge 3 commits into
open-telemetry:mainfrom
serhiy-bzhezytskyy:fix/jaeger-baggage-key-prefix

Conversation

@serhiy-bzhezytskyy

Copy link
Copy Markdown
Contributor

JaegerPropagator._extract_baggage builds the baggage key with key.replace(self.BAGGAGE_PREFIX, ""), which
removes every occurrence of uberctx- rather than the leading one. A carrier key that repeats the prefix loses the
inner literal: uberctx-a-uberctx-b extracts as the baggage key a-b instead of a-uberctx-b. Slicing the prefix
off fixes it.

Adds one test that fails on main with a-b. The test class needs pylint's max-public-methods relaxed for the
added method, the same way propagator/opentelemetry-propagator-b3/tests/test_b3_format.py does.

This touches the same method as #5556, two lines from the byte accounting there, so whichever merges second needs a
trivial rebase.

Assisted-By: Claude Fable 5

@serhiy-bzhezytskyy
serhiy-bzhezytskyy requested a review from a team as a code owner August 19, 2026 04:21
serhiy-bzhezytskyy added a commit to serhiy-bzhezytskyy/opentelemetry-python that referenced this pull request Aug 19, 2026
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 19, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on maintainers · refreshed 2026-08-28 12:08 UTC

Resolve merge conflicts, then merge when ready.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@ocelotl ocelotl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion

continue
context = baggage.set_baggage(
key.replace(self.BAGGAGE_PREFIX, ""),
key[len(self.BAGGAGE_PREFIX) :],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str.removeprefix is available in >=3.10 key.removeprefix(self.BAGGAGE_PREFIX) matches better with the PR title

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

`key.replace(self.BAGGAGE_PREFIX, "")` removes every occurrence, so a carrier key
that repeats the prefix loses the inner literal: `uberctx-a-uberctx-b` became the
baggage key `a-b` instead of `a-uberctx-b`. Slice off the prefix instead.

The class needs pylint's max-public-methods relaxed for the added test, the same way
`propagator/opentelemetry-propagator-b3/tests/test_b3_format.py` does.

Assisted-By: Claude Fable 5
removeprefix reads as what the code does; the package requires
Python >=3.10, well past 3.9 where it was added.
@serhiy-bzhezytskyy
serhiy-bzhezytskyy force-pushed the fix/jaeger-baggage-key-prefix branch from 000751f to bc91c06 Compare August 27, 2026 06:58
@carlosalberto

Copy link
Copy Markdown
Contributor

Although correct, I wonder how valid/common this is :)

@emdneto emdneto moved this to Approved PRs in Python PR digest Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Approved PRs

Development

Successfully merging this pull request may close these issues.

5 participants