Skip to content

Commit 3b7a2e6

Browse files
committed
add changelog
1 parent 4521300 commit 3b7a2e6

2 files changed

Lines changed: 21 additions & 39 deletions

File tree

  • instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Add `BaggageLogProcessor` to `opentelemetry-processor-baggage`
1616
([#4371](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4371))
1717

18+
- `opentelemetry-instrumentation-fastapi`: Clarify documentation for zero-code setup, propagation, and logs
19+
([#4555](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4555))
20+
- `opentelemetry-instrumentation`: Include the package README in the generated documentation
21+
([#4555](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4555))
1822
- `opentelemetry-instrumentation-system-metrics`: Add support for `process.disk.io` metric in system-metrics instrumentation
1923
([#4397](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/4397))
2024
- Switch to SPDX license headers and add CI enforcement

instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,53 +24,31 @@ async def foobar():
2424
FastAPI can also be instrumented without code changes by using the
2525
``opentelemetry-instrument`` command from the
2626
`opentelemetry-instrumentation <https://pypi.org/project/opentelemetry-instrumentation/>`_
27-
package together with the
28-
`opentelemetry-distro <https://pypi.org/project/opentelemetry-distro/>`_
29-
package:
30-
31-
.. code-block:: sh
32-
33-
pip install "opentelemetry-distro[otlp]" opentelemetry-instrumentation-fastapi
34-
opentelemetry-instrument uvicorn app:app
35-
36-
When auto-instrumentation is used with ``opentelemetry-distro``, the SDK
37-
configuration is read from standard OpenTelemetry environment variables such as
38-
``OTEL_SERVICE_NAME``, ``OTEL_TRACES_EXPORTER``, ``OTEL_METRICS_EXPORTER``,
39-
``OTEL_LOGS_EXPORTER``, ``OTEL_EXPORTER_OTLP_ENDPOINT``, and
40-
``OTEL_EXPORTER_OTLP_PROTOCOL``. FastAPI-specific options, such as excluded
41-
URLs and HTTP header capture, are documented below. When using
42-
``FastAPIInstrumentor.instrument_app(app)`` directly, configure the
43-
OpenTelemetry SDK providers and exporters in application code or use a distro
44-
package to configure them.
27+
package. For installation, runtime command, exporter configuration, and
28+
environment variables, see
29+
`Python zero-code instrumentation <https://opentelemetry.io/docs/zero-code/python/>`_.
30+
Install ``opentelemetry-instrumentation-fastapi`` in the same environment so
31+
the FastAPI integration is available to auto-instrumentation. FastAPI-specific
32+
options, such as excluded URLs and HTTP header capture, are documented below.
4533
4634
Trace propagation
4735
*****************
4836
49-
Incoming context is extracted automatically from FastAPI request headers by the
50-
underlying ASGI instrumentation, using the configured global OpenTelemetry
51-
propagator. No manual intervention is needed for incoming HTTP requests.
52-
Outgoing context propagation is handled by the instrumentation for the client
53-
library making the outbound request, such as HTTPX, Requests, or aiohttp.
54-
55-
WebSocket connections are instrumented as ASGI ``websocket`` scopes. Context is
56-
extracted from the WebSocket handshake headers, and spans are created for the
57-
connection and ASGI send/receive events. Propagation data inside WebSocket
58-
message payloads is not parsed automatically.
37+
FastAPI instrumentation uses the underlying ASGI instrumentation, which extracts
38+
incoming context from request headers using the configured global OpenTelemetry
39+
propagator. WebSocket connections are instrumented as ASGI ``websocket`` scopes,
40+
with context extracted from the handshake headers. Propagation data inside
41+
WebSocket message payloads is not parsed automatically. For more information,
42+
see `Python context propagation <https://opentelemetry.io/docs/languages/python/propagation/>`_
43+
and `Python distro configuration <https://opentelemetry.io/docs/languages/python/distro/>`_.
5944
6045
Logs
6146
****
6247
63-
FastAPI instrumentation emits traces and metrics. To export Python ``logging``
64-
records as OpenTelemetry logs, install and enable the
65-
`opentelemetry-instrumentation-logging <https://pypi.org/project/opentelemetry-instrumentation-logging/>`_
66-
package. With auto-instrumentation and ``opentelemetry-distro``, set
67-
``OTEL_LOGS_EXPORTER`` (for example, ``otlp``) to configure log export. Set
68-
``OTEL_PYTHON_LOG_CORRELATION=true`` when log messages should include the
69-
current trace and span IDs in the formatted log output.
70-
71-
OpenTelemetry logs are exported as log records that can be correlated with
72-
traces. They are not added to spans as span events automatically; use
73-
``span.add_event(...)`` for application data that should be recorded as span
48+
FastAPI instrumentation does not convert Python ``logging`` records to span
49+
events. For zero-code log export, see
50+
`Python logs auto-instrumentation <https://opentelemetry.io/docs/zero-code/python/logs-example/>`_.
51+
Use ``span.add_event(...)`` for application data that should be recorded as span
7452
events.
7553
7654
Configuration

0 commit comments

Comments
 (0)