Skip to content

Conversation

liustve
Copy link
Contributor

@liustve liustve commented Aug 29, 2025

Description of changes:
Starlette Instrumentor utilizes the OpenTelemetryMiddleware instrumentation to capture all events generated by ASGI Request received, Response headers sent (http.response.start), Response body sent (http.response.body) which leads to a lot of span noises for streaming events:
image

Luckily, the upstream OpenTelemetryMiddleware provides a configuration in the constructor to suppress these instrumentations: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/51da0a766e5d3cbc746189e10c9573163198cfcd/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py#L573

Enabling this for Agent Observability to help filter out noise.
image

Related issue for removing the need for this patch in the long term, using the proposed OTEL_PYTHON_STARLETTE_EXCLUDED_SPANS environment variable:
open-telemetry/opentelemetry-python-contrib#3725

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@liustve liustve requested a review from a team as a code owner August 29, 2025 00:24
@liustve liustve changed the title Remove http receive/send spans from Starlette Instrumentor Suppress http receive/send spans from Starlette Instrumentor for Agent Observability Aug 29, 2025
@liustve liustve force-pushed the suppress-starlette branch from 7d07715 to 1e35cc6 Compare August 29, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant