Skip to content

Conversation

UltimatePlutoC
Copy link

@UltimatePlutoC UltimatePlutoC commented Sep 28, 2025

…n, websockets, logging, and package links

Description

Summary

This PR adds a new Configuration & Usage Notes section to the FastAPI instrumentation README for issue #3301 . It documents:

  • Supported environment variables for configuration
  • Trace propagation details
  • WebSocket support limitations
  • Logging integration instructions
  • Direct links to relevant PyPI packages

Motivation

This update addresses common questions for users coming from other language ecosystems, clarifies setup via environment variables, and improves discoverability of related packages.

Additional Notes

  • WebSocket trace propagation requires manual instrumentation.
  • Logging integration uses opentelemetry-instrumentation-logging.

Type of change

[x] - Updated documentation

How Has This Been Tested?

Documentation change, no test

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • 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

Copy link

linux-foundation-easycla bot commented Sep 28, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@xrmx xrmx moved this to Ready for review in @xrmx's Python PR digest Sep 30, 2025
@xrmx xrmx moved this from Ready for review to Easy to review / merge / close in @xrmx's Python PR digest Sep 30, 2025
Copilot AI added a commit to UltimatePlutoC/opentelemetry-python-contrib that referenced this pull request Sep 30, 2025
UltimatePlutoC added a commit to UltimatePlutoC/opentelemetry-python-contrib that referenced this pull request Sep 30, 2025
… improvements) (#2)

* Initial plan

* Add changelog entry for PR open-telemetry#3792

Co-authored-by: UltimatePlutoC <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: UltimatePlutoC <[email protected]>
@UltimatePlutoC UltimatePlutoC requested a review from a team as a code owner September 30, 2025 09:14
- ``OTEL_SERVICE_NAME``
- ``OTEL_TRACES_EXPORTER``, ``OTEL_METRICS_EXPORTER``

These can be set to configure exporters, service name, and other options. See the `OpenTelemetry Python documentation <https://opentelemetry-python.readthedocs.io/en/latest/getting-started.html#environment-variables>`_ for a full list.
Copy link
Contributor

Choose a reason for hiding this comment

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

This link seems to be invalid -

image

Also, there is an _ at the end of the link, is that intentional?

Copy link
Contributor

@xrmx xrmx Oct 1, 2025

Choose a reason for hiding this comment

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

@rads-1996 the _ is for links in rst format


**Logging Integration**

To integrate logs as events in traces, use the ``opentelemetry-instrumentation-logging`` package and configure your logger with OpenTelemetry's logging handler. This allows logs to be attached to traces as events. See the `OpenTelemetry Python logging documentation <https://opentelemetry-python.readthedocs.io/en/latest/instrumentation/logging/logging.html>`_.
Copy link
Contributor

Choose a reason for hiding this comment

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

Even this link returns a 404 error


**Related Packages**

- `opentelemetry-instrumentation <https://pypi.org/project/opentelemetry-instrumentation/>`_
Copy link
Contributor

Choose a reason for hiding this comment

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

These two links work fine

Copy link
Member

@emdneto emdneto left a comment

Choose a reason for hiding this comment

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

I suggest to move configuration notes stuff to here

Comment on lines 30 to 36
**Environment Variables**

OpenTelemetry Python supports standard environment variables for configuration, including:

- ``OTEL_EXPORTER_OTLP_ENDPOINT``
- ``OTEL_EXPORTER_OTLP_PROTOCOL``
- ``OTEL_SERVICE_NAME``
Copy link
Member

Choose a reason for hiding this comment

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

I don't think those are necessary since they are well-documented in the SDK scope


Automatic trace propagation for WebSocket connections is limited. You may need to manually create and propagate spans for WebSocket handlers in FastAPI applications.

**Logging Integration**
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest remove the otel-instrumentation-logging package stuff and just replace with the logging.basicConfig setup + OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true environment variable. Like in this example: https://opentelemetry.io/docs/zero-code/python/logs-example/#execute

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, just link to the documentation so we don't duplicate stuff.


**WebSocket Support**

Automatic trace propagation for WebSocket connections is limited. You may need to manually create and propagate spans for WebSocket handlers in FastAPI applications.
Copy link
Member

Choose a reason for hiding this comment

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

Do you think it's possible to add a very basic example on how to do that?

@xrmx xrmx moved this from Easy to review / merge / close to Reviewed PRs that need fixes in @xrmx's Python PR digest Oct 1, 2025
@github-project-automation github-project-automation bot moved this from Reviewed PRs that need fixes to Done in @xrmx's Python PR digest Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants