Skip to content

Commit f7abd95

Browse files
docs(fastapi): add section on environment variables, trace propagation, websockets, logging, and package links
1 parent b0679f1 commit f7abd95

File tree

1 file changed

+31
-1
lines changed
  • instrumentation/opentelemetry-instrumentation-fastapi

1 file changed

+31
-1
lines changed

instrumentation/opentelemetry-instrumentation-fastapi/README.rst

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,37 @@ Installation
2020
pip install opentelemetry-instrumentation-fastapi
2121

2222
References
23-
----------
2423

2524
* `OpenTelemetry Project <https://opentelemetry.io/>`_
2625
* `OpenTelemetry Python Examples <https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples>`_
26+
27+
Configuration & Usage Notes
28+
--------------------------
29+
30+
**Environment Variables**
31+
32+
OpenTelemetry Python supports standard environment variables for configuration, including:
33+
34+
- ``OTEL_EXPORTER_OTLP_ENDPOINT``
35+
- ``OTEL_EXPORTER_OTLP_PROTOCOL``
36+
- ``OTEL_SERVICE_NAME``
37+
- ``OTEL_TRACES_EXPORTER``, ``OTEL_METRICS_EXPORTER``
38+
39+
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.
40+
41+
**Trace Propagation**
42+
43+
Trace context propagation works automatically for HTTP requests. The instrumentation uses W3C Trace Context and Baggage headers for distributed tracing. No manual intervention is required for standard HTTP requests.
44+
45+
**WebSocket Support**
46+
47+
Automatic trace propagation for WebSocket connections is limited. You may need to manually create and propagate spans for WebSocket handlers in FastAPI applications.
48+
49+
**Logging Integration**
50+
51+
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>`_.
52+
53+
**Related Packages**
54+
55+
- `opentelemetry-instrumentation <https://pypi.org/project/opentelemetry-instrumentation/>`_
56+
- `opentelemetry-instrumentation-fastapi <https://pypi.org/project/opentelemetry-instrumentation-fastapi/>`_

0 commit comments

Comments
 (0)