feat(asgi): respect suppress_http_instrumentation in ASGI middleware#4375
Merged
xrmx merged 5 commits intoopen-telemetry:mainfrom Apr 3, 2026
Merged
feat(asgi): respect suppress_http_instrumentation in ASGI middleware#4375xrmx merged 5 commits intoopen-telemetry:mainfrom
xrmx merged 5 commits intoopen-telemetry:mainfrom
Conversation
Add is_http_instrumentation_enabled() check in OpenTelemetryMiddleware.__call__ so ASGI server spans are skipped when HTTP instrumentation is suppressed. Every other HTTP instrumentor (client and server) already honors this flag. ASGI was the only one that did not.
529d0c1 to
fbdd32e
Compare
tammy-baylis-swi
approved these changes
Mar 30, 2026
Contributor
tammy-baylis-swi
left a comment
There was a problem hiding this comment.
Lgtm! Other approvers will have a look
Contributor
Author
|
Awesome, thanks! @tammy-baylis-swi |
liustve
added a commit
to aws-observability/aws-otel-python-instrumentation
that referenced
this pull request
Mar 30, 2026
*Description of changes:* - Suppress redundant HTTP/ASGI spans on MCP client and server by default - Patch `OpenTelemetryMiddleware.__call__` to respect `suppress_http_instrumentation` context note: SHOULD remove this patch once open-telemetry/opentelemetry-python-contrib#4375 is merged - Skip creating MCP spans for initialize and notifications/initialized handshake messages - Introduce `OTEL_MCP_SUPPRESS_HTTP_INSTRUMENTATION` env var, defaults to true <img width="1038" height="546" alt="image" src="https://github.com/user-attachments/assets/d6f0254a-3b4f-4d46-bb32-424d6fee12b3" /> By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
xrmx
approved these changes
Apr 1, 2026
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
ASGI OpenTelemetryMiddleware should respect the
suppress_http_instrumentationcontext and skip server span creation when HTTP instrumentation is suppressed.parities the same feature in aiohttp-server: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py#L446
What changed:
Fixes #4376
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.