-
Notifications
You must be signed in to change notification settings - Fork 783
docs(fastapi): add section on environment variables, trace propagatio… #3301 #3792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: UltimatePlutoC <[email protected]>
… 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]>
- ``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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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>`_. |
There was a problem hiding this comment.
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/>`_ |
There was a problem hiding this comment.
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
There was a problem hiding this 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
**Environment Variables** | ||
|
||
OpenTelemetry Python supports standard environment variables for configuration, including: | ||
|
||
- ``OTEL_EXPORTER_OTLP_ENDPOINT`` | ||
- ``OTEL_EXPORTER_OTLP_PROTOCOL`` | ||
- ``OTEL_SERVICE_NAME`` |
There was a problem hiding this comment.
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** |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
…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:
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
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?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.