Repository navigation
[Tracing] Turn off FastAPI's native OpenTelemetry on SGLang servers - #42769
michaelzhang-ai wants to merge 2 commits into
Conversation
FastAPI 0.142 records request spans, metrics and logs through the global OpenTelemetry providers by default. SGLang installs a global tracer provider for its own request tracing, so FastAPI's spans were exported regardless of the trace level, which broke test_trace_level_0. Opt out on the main, encoder and diffusion HTTP servers; older FastAPI versions get no extra arguments.
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
|
Affected Scope |
|
Thanks for looking. This is now superseded: #43021 (merged 10/13) landed the same change on main at five call sites, including the three here, so I'm closing this one. On NVIDIA, though, the issue isn't backend-specific. FastAPI emits these spans into whatever global tracer provider exists, and If FastAPI's request spans are wanted when tracing is on, gating them on the trace level (FastAPI's |
What
Pass
telemetry={"tracing": False, "metrics": False, "logs": False, "auto_configure": False}toFastAPI()on the main, encoder and diffusion HTTP servers. The new helperfastapi_telemetry_disabled()inobservability/trace.pyreturns these arguments, and returns nothing on FastAPI versions without thetelemetryparameter.Why
FastAPI 0.142.0 (fastapi/fastapi#16403, released 2026-09-29) turned on native OpenTelemetry by default. It now records
POST /generate,fastapi.dependencies,fastapi.endpointandfastapi.serializationspans through the global tracer provider. When tracing is enabled, SGLang installs that same provider for its own request tracing, so FastAPI's spans get exported whatever/set_trace_levelsays.fastapiis unpinned, so CI picked up 0.142.2 on 2026-09-30, andobservability/test_tracing.py::test_trace_level_0has failed since then:Example: https://github.com/sgl-project/sglang/actions/runs/37395620023/job/112050816802
FastAPI's environment auto-configuration would also add a second OTLP exporter to SGLang's provider whenever
OTEL_EXPORTER_OTLP_*is set. This PR turns all four settings off, which puts the servers back to their behavior before 0.142.Test plan
['POST /generate', 'fastapi.dependencies', 'fastapi.endpoint', 'fastapi.serialization']. Withfastapi_telemetry_disabled(): no spans.{}, so the app is constructed exactly as before.observability/test_tracing.pyon MI300 instage-b-test-1-gpu-small-amdpart 8: passed ("passed": true, "elapsed": 202), no spans collected at trace level 0.AssertionError: 6 != 0 : Spans collected but expected none: ['GET /set_trace_level', 'POST /generate', 'fastapi.dependencies', 'fastapi.endpoint'](run).CI States
Latest PR Test (Base): ❌ Run #38317178141
Latest PR Test (Extra): ❌ Run #38317177695
Latest PR Test (AMD ROCm 10): ❌ Run #38317177892