gopidesupavan commented on code in PR #67792:
URL: https://github.com/apache/airflow/pull/67792#discussion_r3330565106


##########
providers/common/ai/docs/observability.rst:
##########
@@ -0,0 +1,96 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+ ..   http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+Observability (OpenTelemetry tracing)
+=====================================
+
+pydantic-ai ships native OpenTelemetry instrumentation that emits GenAI spans
+for each agent run, model call, and tool call, following the
+`OpenTelemetry GenAI semantic conventions 
<https://opentelemetry.io/docs/specs/semconv/gen-ai/>`__.
+When enabled, this provider turns that instrumentation on for every agent it
+builds and routes the spans through the OpenTelemetry exporter Airflow already
+uses, so they appear in whatever backend your deployment runs (Jaeger, Tempo,
+Grafana, Phoenix, Langfuse, an OTLP collector, ...), correlated to the task 
that
+produced them.
+
+This covers all of the LLM operators 
(:class:`~airflow.providers.common.ai.operators.agent.AgentOperator`,
+``@task.agent`` / ``@task.llm`` and the SQL / branch / file-analysis / 
schema-compare
+operators), because they all build their agent through
+:meth:`~airflow.providers.common.ai.hooks.pydantic_ai.PydanticAIHook.create_agent`.
+
+How it works
+------------
+
+* **No extra infrastructure.** The provider does not configure an exporter or a
+  ``TracerProvider`` of its own. It reuses the global provider that Airflow's
+  core tracing installs, so the spans share the exporter and endpoint already
+  configured under ``[traces]`` / the standard ``OTEL_EXPORTER_OTLP_*``
+  environment variables. If core tracing is not enabled in the worker process,
+  no GenAI spans are emitted.
+* **Correlation is automatic.** The worker opens a task span before the 
operator
+  runs, so the agent's spans nest under it and inherit the task's ``trace_id``
+  and ``airflow.*`` attributes (dag id, run id, task id, try number, map 
index).
+  A retry runs in a new process with a new task span, so each attempt is a
+  distinct trace.

Review Comment:
   i think retries starts a new span under the existing 
TaskInstance.context_carrier? should we reword this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to