featherweight.otel¶
otel ¶
OTelObserver: featherweight's spans, in the OpenTelemetry GenAI semantic conventions.
from featherweight import AgentRunner, OTelObserver
runner = AgentRunner(db, observers=[OTelObserver()])
It needs only opentelemetry-api (pip install 'featherweight[otel]'); with no SDK configured the API does nothing, so it costs
nothing. The application configures the SDK and the exporter, as for any other code.
A job is an invoke_workflow span, an attempt of an agent an invoke_agent span, a model call a chat span and a tool call an
execute_tool span. Metadata is always on the spans; content (messages, arguments, results) only when capture_content is on.
Our own attributes are in the ftw. namespace. The conventions are in the Development status and live in their own repository, so
the version we follow is pinned in GENAI_CONVENTIONS, and every attribute we emit is in ATTRIBUTES.
OTelObserver ¶
OTelObserver(
*,
capture_content: bool | None = None,
tracer_provider: TracerProvider | None = None,
)
Bases: Observer
Emits OpenTelemetry spans for jobs, attempts, model calls and tool calls, as the GenAI conventions describe them.
capture_content puts messages, tool arguments and results, and a job's or an agent's input and output on the spans. When it
is not given, it follows OTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENT (SPAN_ONLY is on; anything else, off). Pass a
tracer_provider to use another one than the global one.
submitted
async
¶
submitted(job: JobSubmitted) -> Mapping[str, str] | None
The W3C trace context of the current span, for the message: the worker's job span joins this trace.