Skip to content

A programming framework for agentic AI

Update tracing doc (#6776)

Eric Zhuc92530de1a9a
diff --git a/python/docs/src/user-guide/agentchat-user-guide/tracing.ipynb b/python/docs/src/user-guide/agentchat-user-guide/tracing.ipynb
index 40fcc1a7d..4d3760b5c 100644
--- a/python/docs/src/user-guide/agentchat-user-guide/tracing.ipynb
+++ b/python/docs/src/user-guide/agentchat-user-guide/tracing.ipynb
@@ -99,7 +99,7 @@
"To disable the agent runtime telemetry, you can set the `trace_provider` to\n",
"`opentelemetry.trace.NoOpTraceProvider` in the runtime constructor.\n",
"\n",
- "Additionally, you can set the environment varibale `AUTOGEN_DISABLE_RUNTIME_TRACING` to `true` to disable the agent runtime telemetry if you don't have access to the runtime constructor. For example, if you are using `ComponentConfig`.\n",
+ "Additionally, you can set the environment variable `AUTOGEN_DISABLE_RUNTIME_TRACING` to `true` to disable the agent runtime telemetry if you don't have access to the runtime constructor. For example, if you are using `ComponentConfig`.\n",
"```"
]
},
diff --git a/python/docs/src/user-guide/core-user-guide/framework/telemetry.md b/python/docs/src/user-guide/core-user-guide/framework/telemetry.md
index 1972cc4ef..395ebc028 100644
--- a/python/docs/src/user-guide/core-user-guide/framework/telemetry.md
+++ b/python/docs/src/user-guide/core-user-guide/framework/telemetry.md
@@ -3,9 +3,20 @@
AutoGen has native support for [open telemetry](https://opentelemetry.io/). This allows you to collect telemetry data from your application and send it to a telemetry backend of your choosing.
These are the components that are currently instrumented:
-- Runtime (Single Threaded Agent Runtime, Worker Agent Runtime)
+
+- Runtime ({py:class}`~autogen_core.SingleThreadedAgentRuntime` and {py:class}`~autogen_ext.runtimes.grpc.GrpcWorkerAgentRuntime`).
+- Tool ({py:class}`~autogen_core.tools.BaseTool`) with the `execute_tool` span in [GenAI semantic convention for tools](https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/#execute-tool-span).
+- AgentChat Agents ({py:class}`~autogen_agentchat.agents.BaseChatAgent`) with the `create_agent` and `invoke_agent` spans in [GenAI semantic convention for agents](https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-agent-spans/#create-agent-span).
+
+```{note}
+To disable the agent runtime telemetry, you can set the `trace_provider` to
+`opentelemetry.trace.NoOpTraceProvider` in the runtime constructor.
+
+Additionally, you can set the environment variable `AUTOGEN_DISABLE_RUNTIME_TRACING` to `true` to disable the agent runtime telemetry if you don't have access to the runtime constructor. For example, if you are using `ComponentConfig`.
+```
## Instrumenting your application
+
To instrument your application, you will need an sdk and an exporter. You may already have these if your application is already instrumented with open telemetry.
## Clean instrumentation
@@ -26,6 +37,7 @@ pip install opentelemetry-exporter-otlp-proto-grpc
```
Next, we need to get a tracer provider:
+
```python
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
@@ -44,6 +56,7 @@ def configure_oltp_tracing(endpoint: str = None) -> trace.TracerProvider:
```
Now you can send the trace_provider when creating your runtime:
+
```python
# for single threaded runtime
single_threaded_runtime = SingleThreadedAgentRuntime(tracer_provider=tracer_provider)
@@ -56,6 +69,7 @@ And that's it! Your application is now instrumented with open telemetry. You can
### Existing instrumentation
If you have open telemetry already set up in your application, you can pass the tracer provider to the runtime when creating it:
+
```python
from opentelemetry import trace
@@ -67,3 +81,8 @@ single_threaded_runtime = SingleThreadedAgentRuntime(tracer_provider=tracer_prov
# or for worker runtime
worker_runtime = GrpcWorkerAgentRuntime(tracer_provider=tracer_provider)
```
+
+### Examples
+
+See [Tracing and Observability](../../agentchat-user-guide/tracing.ipynb)
+for a complete example of how to set up open telemetry with AutoGen.