From db4a181ceaf8fb1e260229cfe0182835110b0151 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Jul 2026 01:44:06 +0000 Subject: [PATCH] Document OpenTelemetry instrumentation in sensors user guide Point to the opentelemetry-instrumentation-faust package, which uses the sensor API to trace messages produced to Kafka and events processed by agents. Assisted-by: Claude Fable 5 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01NoKAa2xLqorEdDQKh77E8Q --- docs/userguide/sensors.rst | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/userguide/sensors.rst b/docs/userguide/sensors.rst index 55ce68679..320b2d256 100644 --- a/docs/userguide/sensors.rst +++ b/docs/userguide/sensors.rst @@ -258,6 +258,39 @@ Class: ``TableState`` .. autoattribute:: keys_deleted :noindex: +.. _sensor-opentelemetry: + +OpenTelemetry +============= + +Faust can be instrumented with `OpenTelemetry`_ using the official +`opentelemetry-instrumentation-faust`_ package: + +.. sourcecode:: console + + $ pip install opentelemetry-instrumentation-faust + +The instrumentation uses the sensor API described on this page to +record a producer span for every message sent to Kafka (injecting the +span context into the message headers), and a consumer span for every +event processed by an agent (continuing the trace from the incoming +message headers). + +Instrument faust before creating the app: + +.. sourcecode:: python + + import faust + from opentelemetry.instrumentation.faust import FaustInstrumentor + + FaustInstrumentor().instrument() + + app = faust.App('example', broker='kafka://localhost:9092') + +.. _`OpenTelemetry`: https://opentelemetry.io/ +.. _`opentelemetry-instrumentation-faust`: + https://pypi.org/project/opentelemetry-instrumentation-faust/ + .. _sensor-reference: Sensor API Reference