Repository navigation
Conversation
…Length request headers PEP 3333 passes these two headers as CONTENT_TYPE and CONTENT_LENGTH, without the HTTP_ prefix, so they were never matched by OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST.
Pull request dashboard statusWaiting on the author · refreshed 2026-11-11 14:50 UTC Respond to 2 review items (e.g. link a commit, explain why not, ask a follow-up): Status above doesn't look right?
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the WSGI content-header capture fix.
No open issues 🎉
What changed in this PR
Fixes WSGI request-header capture to include Content-Type and Content-Length from their standard, unprefixed environment keys. Frameworks using the shared WSGI helper also benefit.
Changes:
- Adds non-empty
CONTENT_TYPEandCONTENT_LENGTHvalues to the existing sanitization pipeline, taking precedence over prefixed equivalents. - Adds regression coverage for capture, precedence, and empty-value handling.
- Documents the fix in a changelog entry.
| File | Description |
|---|---|
| instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py | Tests content-header capture, precedence, and empty-length omission. |
| instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py | Includes unprefixed content headers in request-header capture. |
| .changelog/5321.fixed | Records the WSGI header-capture fix. |
Review effort: Balanced
xrmx
reviewed
Nov 11, 2026
Contributor
|
Also would be nice to have docker tests added to the current django and flask ones for these fields and also something HTTP_ prefixed |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
collect_custom_request_headers_attributesonly looks at theHTTP_*keys of the environ. PEP 3333 passesContent-TypeandContent-LengthasCONTENT_TYPEandCONTENT_LENGTH, so they are never captured, although the module docs usecontent-typeas the example forOTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST. The ASGI instrumentation does capture them.Add the two keys to the headers passed to the sanitizer when they are not empty. If a server sets
HTTP_CONTENT_TYPEas well, the unprefixed value wins, which is what werkzeug does. Flask, Falcon, Pyramid and Django (WSGI) collect their headers through this function, so they get the fix too.One thing to be aware of: some servers fill in
CONTENT_TYPEwhen the client did not send one (wsgiref usestext/plain), and that value is captured as well.Type of change
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
tox -e precommittox -e typecheck