Repository navigation
feat: make the ASGI receive/send spans opt-out on Litestar - #288
Merged
Merged
Conversation
LitestarConfig gets the same opentelemetry_exclude_spans field as FastAPIConfig and passes it to Litestar's OpenTelemetryConfig, which has taken exclude_spans since 2.22, the litestar-otl floor.
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.
Closes #287.
Adds
opentelemetry_exclude_spanstoLitestarConfigand passes it toLitestarOpenTelemetryConfig(exclude_spans=...). FastAPI has had this since #225.Same shape as FastAPI
The field stays on each framework config, not the shared
OpenTelemetryConfig, because the FastStream and FastMCP bootstrappers have nothing to pass it to. The FastAPI comment said Litestar's instrumentor lacked the parameter. That was wrong, and the comment now names both frameworks.The default is an empty list, so existing services keep all their spans. The value is passed unconditionally, as on FastAPI: the ASGI middleware treats
[]and Litestar's defaultNonethe same way.No dependency change
Litestar's
OpenTelemetryConfighas hadexclude_spanssince 2.22, andlitestar-otlalready requireslitestar>=2.22. I checked the 2.22.0 wheel directly.Tests
The tests run a real request through the bootstrapped app with an in-memory exporter. The default test asserts that an INTERNAL span (an ASGI event span) is recorded. The new test asserts that with
["receive", "send"]only the SERVER span remains. Before the change it failed withunexpected keyword argument 'opentelemetry_exclude_spans'.The configuration and performance docs no longer say "FastAPI only".