Skip to content

feat: drop the ASGI send/receive spans from traces - #64

Merged
lesnik512 merged 2 commits into
mainfrom
feat/exclude-asgi-event-spans
Oct 16, 2026
Merged

lesnik512 merged 2 commits into
mainfrom
feat/exclude-asgi-event-spans

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Upgrades lite-bootstrap to 1.13.0 and sets opentelemetry_exclude_spans=["receive", "send"] in api_bootstrapper_config. This is the Litestar counterpart of modern-python/fastapi-sqlalchemy-template#86. lite-bootstrap 1.13.0 added the option for Litestar in modern-python/lite-bootstrap#288.

Upgrade, 1.9.2 to 1.13.0

pyproject.toml now requires lite-bootstrap[litestar-all]>=1.13, because the setting doesn't exist in earlier versions. The lock moves only lite-bootstrap. The upgrade includes two breaking changes:

  • lite-bootstrap#279 traces Litestar through Litestar's own OpenTelemetryPlugin.
  • lite-bootstrap#270 drops Python 3.10, which doesn't affect this template.

The suite passed on the upgrade alone, before any other change.

Why drop the spans

A traced GET /api/decks/{id}/ records 6 spans: the server span, 2 http send spans, connect and 2 SELECT. The send spans rarely matter for a JSON API, and dropping them is cheap. Same harness as #63, medians of 3 runs, in req/s:

1 client 100 clients
no tracing 1585 1558
always on 896 953
always on, send/receive excluded 963 1006
10% ratio sampler 1211 1162
10% ratio sampler, send/receive excluded 1255 1208

The README notes the setting and says to remove it if those spans are needed.

Tests

The tracing test now also checks that, apart from SQLAlchemy spans, a traced request records only the SERVER span. Without the setting it fails, because two INTERNAL event spans appear.

I added this check to the existing test instead of writing a second one. A second traced test would call build_app() with tracing again in the same process, and lite-bootstrap 1.13 warns that a TracerProvider is already installed (lite-bootstrap#264).

Sets opentelemetry_exclude_spans=["receive", "send"], so a traced request
records its server span and database spans only.
@lesnik512
lesnik512 merged commit c3cba82 into main Oct 16, 2026
2 checks passed
@lesnik512
lesnik512 deleted the feat/exclude-asgi-event-spans branch October 16, 2026 11:13
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