Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/4555.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`opentelemetry-instrumentation-fastapi`, `opentelemetry-instrumentation`: update docs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to be a bit more specific here

7 changes: 5 additions & 2 deletions docs/instrumentation/base/instrumentation.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
OpenTelemetry Python Instrumentor
=================================
.. include:: ../../../opentelemetry-instrumentation/README.rst
Comment thread
Harshal96 marked this conversation as resolved.
:end-before: References

API
---

.. automodule:: opentelemetry.instrumentation
:members:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,39 @@ async def foobar():

FastAPIInstrumentor.instrument_app(app)

Auto-instrumentation
Comment thread
tammy-baylis-swi marked this conversation as resolved.
********************

FastAPI can also be instrumented without code changes by using the
``opentelemetry-instrument`` command from the
`opentelemetry-instrumentation <https://pypi.org/project/opentelemetry-instrumentation/>`_
package. For installation, runtime command, exporter configuration, and
environment variables, see
`Python zero-code instrumentation <https://opentelemetry.io/docs/zero-code/python/>`_.
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
Comment thread
tammy-baylis-swi marked this conversation as resolved.
*****************

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 <https://opentelemetry.io/docs/languages/python/propagation/>`_
and `Python distro configuration <https://opentelemetry.io/docs/languages/python/distro/>`_.

Logs
Comment thread
tammy-baylis-swi marked this conversation as resolved.
****

FastAPI instrumentation does not convert Python ``logging`` records to span
events. For zero-code log export, see
`Python logs auto-instrumentation <https://opentelemetry.io/docs/zero-code/python/logs-example/>`_.
Use ``span.add_event(...)`` for application data that should be recorded as span
events.

Configuration
-------------

Expand Down