You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pass exclude_spans to FastAPIInstrumentor so ASGI send/receive spans are opt-out #185
instrument_app also accepts exclude_spans: list[Literal["receive", "send"]] (opentelemetry-instrumentation-fastapi, instrument_app signature). Without it, every request produces three spans: the server span plus one each for the ASGI receive and send events. Most users never look at the latter two.
What it costs
Same harness as the sampler issue: async def endpoint, only the OpenTelemetry instrument on, OTLP/HTTP to a local stub sink, in-process ASGI driving. Apple M2, CPython 3.14.7, opentelemetry-instrumentation-fastapi 0.65b0.
scenario
RPS
µs/req
as configured today
7375
135.6
exclude_spans=["receive", "send"]
9755
102.5
that plus a 1% ratio sampler (other issue)
15922
62.8
33 µs/request, a quarter of the instrument's cost, for two thirds of the spans.
Proposal
Add opentelemetry_exclude_spans: list[Literal["receive", "send"]] = [] to OpenTelemetryConfig (or a FastAPI-scoped equivalent) and pass it through.
Worth discussing whether the default should be [] (today's behaviour, no surprise on upgrade) or ["receive", "send"] (cheaper, and matches what most people actually read in a trace view). I lean towards keeping [] and documenting the knob, since dropping spans silently changes what shows up in Jaeger/Tempo for existing users.
Note this parameter is FastAPI-specific; Litestar's instrumentor has its own shape, so the config field may want to live on the FastAPI config rather than the shared one.
The snippet in the body is stale. _narrow_app was deleted in #196; FastAPIConfig now exposes an app property that does the same narrowing past the UNSET sentinel.
Nothing about this issue changes: exclude_spans is still not passed, and the call site is still the one place to pass it. Only the spelling of the first argument moved.
Activity
chore(benchmarks): add the observability-overhead harness and its fin…
chore(benchmarks): add the observability-overhead harness and its fin…
lesnik512 commentedon Sep 12, 2026
The snippet in the body is stale.
_narrow_appwas deleted in #196;FastAPIConfignow exposes anappproperty that does the same narrowing past theUNSETsentinel.So this:
is now, in
FastAPIOpenTelemetryInstrument.bootstrap():Nothing about this issue changes:
exclude_spansis still not passed, and the call site is still the one place to pass it. Only the spelling of the first argument moved.feat: make the ASGI receive/send spans opt-out on FastAPI
feat: make the ASGI receive/send spans opt-out on FastAPI
feat: make the ASGI receive/send spans opt-out on FastAPI (#225)