Skip to main content
The SDK has two observability layers:
  1. OpenTelemetry export — distributed traces, metrics, and structured logs pushed to any OTLP-compatible backend (Jaeger, Grafana, Datadog, etc.). Configured once at agent creation.
  2. Run-level telemetryAgentTelemetry on every AgentRunResult. LLM round counts, tool breakdowns, and storage operation summaries returned inline with each result. No configuration required.

Enable OpenTelemetry

Pass WithObservabilityConfig to wire traces, metrics, and logs in one block:
Use the same 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:
See Tracing, Metrics, and Logs for per-signal details and collector configuration.

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: Fields are zero when the corresponding feature is not configured (no retriever → retriever counts are 0; no memory → memory counts are 0).

Run telemetry

max_iterations means the run hit WithMaxIterations before producing a final answer.

Tool telemetry

Covers native tools, MCP tools, retriever tools, and sub-agent delegation tools.

Storage telemetry

See Retrieval and Memory for when each counter increments.

Run

Example: Simple Agent · Observability.

Stream

Telemetry is on Result.Telemetry inside the AgentEventTypeRunFinished event:

Token usage vs telemetry

See Token Usage.

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

Metrics

OTLP counters and histograms

Tracing

Distributed spans per LLM and tool call