- OpenTelemetry export — distributed traces, metrics, and structured logs pushed to any OTLP-compatible backend (Jaeger, Grafana, Datadog, etc.). Configured once at agent creation.
- Run-level telemetry —
AgentTelemetryon everyAgentRunResult. LLM round counts, tool breakdowns, and storage operation summaries returned inline with each result. No configuration required.
Enable OpenTelemetry
PassWithObservabilityConfig to wire traces, metrics, and logs in one block:
WithObservabilityConfig on NewAgent and NewAgentWorker. LLM calls and tool executions run on the worker process — without matching config those spans and metrics are dropped.
Opt out of individual signals:
Run-level telemetry (AgentTelemetry)
Every completed run populates AgentTelemetry on AgentRunResult. This is run-level behavioral data returned with the result — separate from OTLP export. Use it for app-side logging, dashboards, and eval harness assertions.
Structure
AgentTelemetry has three sections:
| Section | Tracks |
|---|---|
Run | Orchestration lifecycle — timing, LLM round count, finish reason |
Tools | Tool invocation totals, failures, per-tool breakdown |
Storage | Retriever searches and memory recall/store operations |
Run telemetry
| Field | Description |
|---|---|
StartedAt | Run start time |
CompletedAt | Run completion time |
TotalLLMCalls | LLM calls across all tool rounds |
FinishReason | complete or max_iterations |
max_iterations means the run hit WithMaxIterations before producing a final answer.
Tool telemetry
| Field | Description |
|---|---|
TotalCalls | Total tool invocations |
FailedCalls | Tools that returned an error — excludes approval-denied and unauthorized cases |
Breakdown | Per-tool invocation counts — key is tool name |
FailedBreakdown | Per-tool failure counts |
Storage telemetry
| Field | Description |
|---|---|
TotalRetrieverSearches | Total RAG searches |
FailedRetrieverSearches | Failed retriever searches |
PrefetchSearches | Searches from prefetch or hybrid mode |
AgenticSearches | Searches from agentic or hybrid mode (LLM-initiated) |
TotalMemoryRecalls | Memory load operations before the run |
FailedMemoryRecalls | Failed recall operations |
TotalMemoryStores | Memory persist operations |
FailedMemoryStores | Failed store operations |
Run
Stream
Telemetry is onResult.Telemetry inside the AgentEventTypeRunFinished event:
RunAsync
Same asRun — telemetry is on the final AgentRunAsyncResult.Result.Telemetry when the run completes.
Token usage vs telemetry
| Data | Where | Purpose |
|---|---|---|
| Telemetry | Result.Telemetry | Run behavior — LLM round count, tool breakdown, storage ops |
| Token usage | Result.LLMUsage | Aggregate token counts for cost and quota tracking |
Eval harness
Telemetry fields are designed for eval assertions — total LLM calls, tool breakdown, finish reason, and storage counts. See Eval Harness.Example
Telemetry
SHOW_TELEMETRY on run results
Related
Metrics
OTLP counters and histograms
Tracing
Distributed spans per LLM and tool call
Token Usage
LLMUsage on run results
Observability Example
Runnable demo with telemetry footer