Skip to content

opentelemetry-instrumentation-urllib3: keep pool headers when urlopen is called without headers - #5320

Open
ghdtjdwn wants to merge 2 commits into
open-telemetry:mainfrom
ghdtjdwn:urllib3/keep-pool-headers
Open

ghdtjdwn wants to merge 2 commits into
open-telemetry:mainfrom
ghdtjdwn:urllib3/keep-pool-headers

Conversation

@ghdtjdwn

Copy link
Copy Markdown
Contributor

Description

HTTPConnectionPool.urlopen() uses the pool's default headers when it is called without headers. The instrumented urlopen turns the missing headers into {} before injecting the propagation headers and passes that on, so urllib3 never falls back to pool.headers and the defaults set on the pool are not sent.

pool = urllib3.HTTPConnectionPool("example.com", headers={"X-Test": "Value"})
pool.urlopen("GET", "/")  # X-Test is not sent once urllib3 is instrumented

Start from a copy of instance.headers in that case. pool.request() and PoolManager pass the headers explicitly, so only direct urlopen() calls were affected. For those calls the pool headers now also show up in RequestInfo.headers and in the captured http.request.header.* attributes.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • I am a human and not a bot
  • I have run tox -e precommit
  • I have run tox -e typecheck
  • I have run the relevant tests and linting tox environments
  • This requires the following PR in core: none

… gets none

urllib3 falls back to the pool's default headers when urlopen() is called
without headers. The instrumented urlopen replaced the missing headers
with an empty dict before injecting, so the pool defaults were never
sent. Start from a copy of the pool headers instead.
@ghdtjdwn
ghdtjdwn requested a review from a team as a code owner November 11, 2026 01:31
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-11-11 01:38 UTC

Review the latest changes.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant