Repository navigation
feat: drop the ASGI send/receive spans from traces - #86
Merged
Merged
Conversation
Sets opentelemetry_exclude_spans=["receive", "send"], so a traced request records its server span and database spans only.
This was referenced Oct 16, 2026
Merged
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.
Sets
opentelemetry_exclude_spans=["receive", "send"]inapi_bootstrapper_config. lite-bootstrap passes it toFastAPIInstrumentor.instrument_app(lite-bootstrap #225, available since 1.8.0; the template is on 1.9.3).Why
A traced
GET /api/decks/{id}/records 6 spans: the server span, 2http sendspans,connectand 2SELECT. The two send spans mark when the response start and body went out, which is rarely worth looking at for a JSON API. Dropping them is cheap. The benchmark below is the same harness as #85: the full app driven through raw ASGI, with the OTLP exporter encoding spans and then dropping them. Medians of 3 runs, in req/s:The README notes the setting and says to remove it if those spans are needed.
Tests
test_request_has_no_asgi_event_spanssends a realGET /api/decks/and asserts that, apart from SQLAlchemy spans, the only span recorded is the SERVER span. It failed before the settings change, when INTERNAL event spans were present.litestar-sqlalchemy-template will get the same change once lite-bootstrap releases modern-python/lite-bootstrap#288.