Wire OTLP
UseWithObservabilityConfig — the same block configures traces, metrics, and logs:
Bring your own metrics
WithObservabilityConfig enables metrics, any WithMetrics value is replaced by the OTLP client built from config.
For advanced tuning (metrics export interval, headers, sampling), use observability.NewMetrics with observability.Option directly.
Agent API metrics
Emitted byAgent.Run and Agent.Stream:
Stream metrics cover the dispatch phase — not per-token streaming duration.
Runtime metrics
Emitted per LLM call, tool execution, retriever search, and memory operation on the in-process, Temporal, and Restate runtimes.LLM
Tools
Retriever
Memory
Each memory operation family has
.started, .completed, .failed counters and a .latency_ms histogram.
Common attributes
Runtime metrics include attributes when available:Export to Prometheus
The SDK pushes OTLP metrics — it does not expose a Prometheus scrape endpoint directly. Use the OpenTelemetry Collector as a bridge: receive OTLP from the SDK and expose a/metrics endpoint for Prometheus to scrape.
Minimal otel-collector-config.yaml:
scrape_configs entry:
localhost:4317 (OTLP gRPC), the collector bridges to Prometheus on :8889:
Telemetry vs metrics
See Telemetry.
Example
Observability
OTLP traces, metrics, and logs
Related
Tracing
Distributed spans for the same operations
Token Usage
Per-run token totals on AgentRunResult