airflow.providers.common.ai.observability¶
OpenTelemetry tracing for pydantic-ai agents created by this provider.
pydantic-ai ships native OpenTelemetry instrumentation that emits GenAI spans (agent run, model call, tool call) following the OTel GenAI semantic conventions. This module turns it on and points it at Airflow’s existing OpenTelemetry exporter so agent spans flow to whatever OTLP backend the deployment already runs, nested under the worker’s task span.
It deliberately does not configure an exporter or a TracerProvider of its
own: it reuses the global SDK provider that core tracing ([traces] otel_on)
installs in the worker process. When that provider is absent (core tracing off,
or not configured in this process) no spans are emitted.
Attributes¶
Functions¶
Build pydantic-ai |
|
Build the Airflow identity attributes to stamp on a run's GenAI spans. |
|
|
Stamp attributes on every GenAI span agent emits during its run. |
Module Contents¶
- airflow.providers.common.ai.observability.genai_instrumentation_settings()[source]¶
Build pydantic-ai
InstrumentationSettingsfor an agent run.Returns
None(leave the agent un-instrumented, zero overhead) when export is disabled or no live OTLPTracerProvideris configured in this worker process.include_contentis off by default so prompts, completions, and tool IO are never emitted unless explicitly opted in via[common.ai] capture_content.
- airflow.providers.common.ai.observability.build_run_identity_attributes(ti)[source]¶
Build the Airflow identity attributes to stamp on a run’s GenAI spans.
Reuses core’s task-span attribute keys (see
_make_task_span) so agent spans filter identically to the task span they nest under, plus the per-attempt task-instance id as the run join key carried on every span.
- airflow.providers.common.ai.observability.stamp_identity_on_agent_spans(agent, attributes)[source]¶
Stamp attributes on every GenAI span agent emits during its run.
pydantic-ai opens all of a run’s agent/model/tool spans from
InstrumentationSettings.tracer, so wrapping that one tracer reaches them all without touching the shared coreTracerProvider. No-op when the agent is not instrumented with anInstrumentationSettings(tracing off, or the caller supplied its own non-settingsinstrumentvalue).The settings object may be caller-owned and shared across agents (a single module-level
InstrumentationSettingshanded to several tasks) or reused across HITL re-runs. Mutating it in place would leak one run’s identity into another and nest_IdentityTracerwrappers on each stamp, so we wrap a copy and swap it onto this agent, leaving the original untouched.