diff --git a/.changelog/4555.added b/.changelog/4555.added new file mode 100644 index 0000000000..daafeca51a --- /dev/null +++ b/.changelog/4555.added @@ -0,0 +1 @@ +`opentelemetry-instrumentation-fastapi`, `opentelemetry-instrumentation`: update docs diff --git a/docs/instrumentation/base/instrumentation.rst b/docs/instrumentation/base/instrumentation.rst index 9c01b6b6f4..c3ee9da976 100644 --- a/docs/instrumentation/base/instrumentation.rst +++ b/docs/instrumentation/base/instrumentation.rst @@ -1,5 +1,8 @@ -OpenTelemetry Python Instrumentor -================================= +.. include:: ../../../opentelemetry-instrumentation/README.rst + :end-before: References + +API +--- .. automodule:: opentelemetry.instrumentation :members: diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py index ab936f0ed5..31bcfd96dc 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py @@ -18,6 +18,39 @@ async def foobar(): FastAPIInstrumentor.instrument_app(app) +Auto-instrumentation +******************** + +FastAPI can also be instrumented without code changes by using the +``opentelemetry-instrument`` command from the +`opentelemetry-instrumentation `_ +package. For installation, runtime command, exporter configuration, and +environment variables, see +`Python zero-code instrumentation `_. +Install ``opentelemetry-instrumentation-fastapi`` in the same environment so +the FastAPI integration is available to auto-instrumentation. FastAPI-specific +options, such as excluded URLs and HTTP header capture, are documented below. + +Trace propagation +***************** + +FastAPI instrumentation uses the underlying ASGI instrumentation, which extracts +incoming context from request headers using the configured global OpenTelemetry +propagator. WebSocket connections are instrumented as ASGI ``websocket`` scopes, +with context extracted from the handshake headers. Propagation data inside +WebSocket message payloads is not parsed automatically. For more information, +see `Python context propagation `_ +and `Python distro configuration `_. + +Logs +**** + +FastAPI instrumentation does not convert Python ``logging`` records to span +events. For zero-code log export, see +`Python logs auto-instrumentation `_. +Use ``span.add_event(...)`` for application data that should be recorded as span +events. + Configuration -------------