Skip to content

Document FastAPI instrumentation setup#4555

Open
Harshal96 wants to merge 3 commits intoopen-telemetry:mainfrom
Harshal96:doc-fastapi-doc-holes
Open

Document FastAPI instrumentation setup#4555
Harshal96 wants to merge 3 commits intoopen-telemetry:mainfrom
Harshal96:doc-fastapi-doc-holes

Conversation

@Harshal96
Copy link
Copy Markdown

Description

Clarifies the FastAPI instrumentation docs for auto-instrumentation environment configuration, trace propagation, WebSocket behavior, and log export. Also renders the opentelemetry-instrumentation README in the generated docs so the opentelemetry-instrument package has a clearer docs menu entry.

Fixes #3301

Type of change

  • This change requires a documentation update

How Has This Been Tested?

  • python3 -m py_compile instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py
  • uv 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__.py
  • git diff --check

Full 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 unrelated mysqlclient==2.2.8 build requires pkg-config/MySQL client build flags.

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

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
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 8, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@Harshal96 Harshal96 marked this pull request as ready for review May 8, 2026 10:16
@Harshal96 Harshal96 requested a review from a team as a code owner May 8, 2026 10:16
@tammy-baylis-swi
Copy link
Copy Markdown
Contributor

Thank you @Harshal96 !

Please could you update this reference as per tox -e docs ci/cd:

sphinx.errors.SphinxWarning: /home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/opentelemetry-instrumentation/README.rst:27:'any' reference target not found: opentelemetry_distro

Also could you please add a changelog entry, since it's more than a few lines.


FastAPIInstrumentor.instrument_app(app)

Auto-instrumentation
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.

I think it's good to make this update based on how OP found the docs, though the issue pre-dates some major changes to the otel.io docs.

Could these sections be simplified to point to pages like this one, instead of duplicating and adding a bit of maintainance burden?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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
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.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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
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.

Maybe we could just link here instead: https://opentelemetry.io/docs/zero-code/python/logs-example/

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

@tammy-baylis-swi tammy-baylis-swi moved this to Reviewed PRs that need fixes in Python PR digest May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

Doc holes in FastAPI instrumentation

2 participants