Document FastAPI instrumentation setup#4555
Document FastAPI instrumentation setup#4555Harshal96 wants to merge 3 commits intoopen-telemetry:mainfrom
Conversation
Clarify FastAPI auto-instrumentation configuration, propagation, WebSocket behavior, and log export. Also surface the opentelemetry-instrumentation README in the generated docs menu. Assisted-by: OpenAI Codex
|
Thank you @Harshal96 ! Please could you update this reference as per
Also could you please add a changelog entry, since it's more than a few lines. |
|
|
||
| FastAPIInstrumentor.instrument_app(app) | ||
|
|
||
| Auto-instrumentation |
There was a problem hiding this comment.
There was a problem hiding this comment.
Updated the comment to point to the linked page
| OpenTelemetry SDK providers and exporters in application code or use a distro | ||
| package to configure them. | ||
|
|
||
| Trace propagation |
There was a problem hiding this comment.
What's in this section is useful. Would you consider making an update to this page and/or this page instead of this doc specific to FastAPI? The otel.io docs are sourced in this repo: https://github.com/open-telemetry/opentelemetry.io
There was a problem hiding this comment.
Makes sense, updated comment to reflect fastapi usage, will open a new PR in main repo for distro and propagation pages
| connection and ASGI send/receive events. Propagation data inside WebSocket | ||
| message payloads is not parsed automatically. | ||
|
|
||
| Logs |
There was a problem hiding this comment.
Maybe we could just link here instead: https://opentelemetry.io/docs/zero-code/python/logs-example/
Description
Clarifies the FastAPI instrumentation docs for auto-instrumentation environment configuration, trace propagation, WebSocket behavior, and log export. Also renders the
opentelemetry-instrumentationREADME in the generated docs so theopentelemetry-instrumentpackage has a clearer docs menu entry.Fixes #3301
Type of change
How Has This Been Tested?
python3 -m py_compile instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.pyuv run --no-project --with docutils --with pygments python3 -c "...FastAPI docstring RST parsed..."uv run --no-project --with docutils python3 -c "...opentelemetry-instrumentation README RST parsed..."uv run --no-project --with ruff ruff check instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.pygit diff --checkFull docs build was attempted with
uv run sphinx-build -W --keep-going -b html docs docs/_build/html, but this local machine could not complete the workspace sync because the unrelatedmysqlclient==2.2.8build requirespkg-config/MySQL client build flags.Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.