Skip to main content
Dual export from a Python service. Built from the example examples/otel-python-fastapi: FastAPI 0.161.1 on uvicorn 0.54.0 with opentelemetry-instrumentation-fastapi 0.66b2 and the OpenTelemetry Python SDK 1.45.2, on Python 3.14.10 with uv. tests/otelapps runs it against stock collectors in every export mode, including both semantic convention settings below, and the apipath tag runs it against the real platform collector. Read the API quickstart first for the token and the environment variables.

Packages

The instrumentation packages are published only as beta versions (0.66b2); pin them exactly, as here, to the release that matches the SDK version.

OTEL_SEMCONV_STABILITY_OPT_IN

Set OTEL_SEMCONV_STABILITY_OPT_IN=http. The example’s image sets it:
Both tested settings give the same numbers in the dashboard; http avoids the conversion.

The SDK setup

Two exporters per signal; only the platform exporters carry the token:

Instrumenting the app

Pass both providers to the instrumentor explicitly. Health checks are excluded so probes do not count as API traffic:
FastAPI’s instrumentation sets http.route from the path template (/accounts/{account_id}); see http-route.md.

Notes

  • Shut down cleanly. Shut down the meter provider and the tracer provider at the end of the app’s lifespan, after uvicorn stopped accepting requests, so the last interval is exported (see lifespan in app.py).
  • Delta temporality follows the specification’s delta preference: counters and histograms switch to delta, up-down counters and gauges stay cumulative.

Export modes the tests cover