Skip to content

opentelemetry-instrumentation-aiohttp-server: capture all values of repeated headers - #5322

Open
ghdtjdwn wants to merge 2 commits into
open-telemetry:mainfrom
ghdtjdwn:aiohttp-server/repeated-headers
Open

ghdtjdwn wants to merge 2 commits into
open-telemetry:mainfrom
ghdtjdwn:aiohttp-server/repeated-headers

Conversation

@ghdtjdwn

Copy link
Copy Markdown
Contributor

Description

request.headers and response.headers are multidicts and are passed to SanitizeValue.sanitize_header_values as they are. That function assigns one list per key while iterating .items(), so for a header that appears more than once only the last value ends up in http.request.header.<name> / http.response.header.<name>. The aiohttp client and ASGI instrumentations record every value.

Group the values by lowercased header name before handing them to the sanitizer. I did not reuse the {key: headers.getall(key) for key in headers.keys()} form from the client instrumentation, because it calls getall once per header line and that gets slow when a request repeats the same header many times. collect_response_headers_attributes now returns early when no response headers are configured, as the request side already does, so nothing is built in that case.

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

…epeated headers

The request and response headers are multidicts, and passing them to
sanitize_header_values as is kept only the last value of a header that
appears more than once. Group the values by header name first.
@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:39 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