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
Commit 04c278e
Browse filesBrowse the repository at this point in the historyBrowse files
perf: skip SDK tracing without span processors (#402) (#430)
Preserve an external provider installed before bootstrap. Otherwise pass a local
NoOpTracerProvider to framework and custom instrumentors without consuming the
global registration slot. Keep SDK providers for configured span processors and
leave external provider shutdown to its owner.
Metrics-only and external-provider warning regressions failed first. Both OTLP
exporter protocols still record and export. FastAPI/Litestar HTTP tests verify
metrics collection and provider setup before/after bootstrap.
Local Python 3.14.7 metrics-only ASGI benchmark: 500 warmup requests, seven rounds
of 5000 requests, median elapsed request time. Metrics used ConsoleMetricExporter
with an in-memory output stream to exclude network I/O. Logging, Prometheus and
health routes disabled. Same harness and environment before/after:
- FastAPI: 148.83 -> 108.39 us/request
- Litestar: 108.17 -> 77.70 us/request
Validation: 628 tests passed with 100% coverage; lint, ty and strict docs build
passed. Standards and spec reviews found no remaining issues.
Copy file name to clipboardExpand all lines: docs/introduction/configuration.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,6 +232,28 @@ Additional parameters:
232
232
-`opentelemetry_excluded_urls` - extra regexes for URLs excluded from tracing; the metrics path and (unless health-check spans are enabled) the health-check path are excluded automatically. Litestar searches them in the request path, FastAPI and FastMCP in the full URL. FastAPI and FastMCP raise `ConfigurationError` at config construction if an entry contains a comma because OpenTelemetry uses commas to separate patterns. Litestar accepts commas in config entries. The environment variable OpenTelemetry defines for the framework (`OTEL_PYTHON_LITESTAR_EXCLUDED_URLS`, `OTEL_PYTHON_FASTAPI_EXCLUDED_URLS` or `OTEL_PYTHON_STARLETTE_EXCLUDED_URLS` for FastMCP), falling back to `OTEL_PYTHON_EXCLUDED_URLS`, adds to them.
233
233
-`opentelemetry_metrics_endpoint` - will be passed to `OTLPMetricExporter` as endpoint, and turns on the metrics signal. Its own field rather than a flag on `opentelemetry_endpoint`, so upgrading never starts exporting metrics you did not ask for. Under `opentelemetry_exporter_protocol="http"` this is a full URL (e.g. `http://collector:4318/v1/metrics`); `opentelemetry_exporter_protocol` and `opentelemetry_insecure` are shared with traces.
234
234
235
+
### Tracing without span processors
236
+
237
+
lite-bootstrap installs an SDK `TracerProvider` only when it adds a span processor:
238
+
Pyroscope span correlation, `opentelemetry_log_traces=True`, or a trace endpoint
239
+
with its exporter installed. Metrics-only configuration does not create an SDK
240
+
tracer provider. A trace endpoint with a missing exporter still warns, but uses
241
+
no-op tracing if no other span processor is configured.
242
+
243
+
Without span processors, framework and custom instrumentors receive a local
244
+
`NoOpTracerProvider` unless an external tracer provider is already installed.
245
+
An existing external provider is preserved and is never shut down by lite-bootstrap.
246
+
Install an external provider before bootstrap if it should record framework spans.
247
+
The no-op path leaves the global provider registration slot available, but installing
248
+
an external provider afterward does not replace the no-op provider already passed
249
+
to framework and custom instrumentors.
250
+
251
+
Code that previously added a span processor to `get_tracer_provider()` after a
252
+
metrics-only bootstrap must instead create and install its own SDK provider before
253
+
bootstrap. For metrics-only requests without external tracing, spans do not record
254
+
and JSON logs omit `tracing`; there are no `span_id` or `trace_id` values to inject.
255
+
Metrics collection is unchanged.
256
+
235
257
### Metrics
236
258
237
259
Left unset, no `MeterProvider` is installed and the metrics signal stays off. Set it, and the
0 commit comments