Skip to content
Back to all articles

Published ·

OpenTelemetry for AI Agents

AI agents are distributed systems with a mind of their own. OpenTelemetry gives you the traces, metrics, and logs to actually understand what they're doing.

OpenTelemetry Observability AI Agents

An AI agent looks simple from the outside: a prompt goes in, an answer comes out. Inside, it’s anything but. A single request can fan out into multiple model calls, tool invocations, retrieval steps, and retries — often across several services. When something goes wrong (a wrong answer, a slow response, a runaway bill), you need to see exactly what happened. That’s what OpenTelemetry gives you.

Why agents are hard to debug

Traditional logging falls apart with agents because:

  • The control flow is non-deterministic. The same input can take different paths depending on what the model decides.
  • Work is distributed. Tool calls hit other services; retrieval hits a vector store; the model lives behind an API.
  • Cost and latency are emergent. A small change in a prompt can double the number of tokens or tool calls.

You can’t reason about that from scattered print statements. You need correlated, end-to-end visibility.

What OpenTelemetry brings

OpenTelemetry (OTel) is the vendor-neutral standard for telemetry — traces, metrics, and logs — and it’s a perfect fit for agents.

Traces

A trace captures one end-to-end request as a tree of spans. For an agent, that means a single trace can show:

  • the top-level user request,
  • each model call (with model name, latency, and token counts),
  • each tool invocation (with arguments and results),
  • retrieval steps and their latency.

Suddenly “the agent was slow” becomes “the third tool call took 8 seconds waiting on an external API.”

Metrics

Aggregate signals you watch over time: tokens per request, cost per request, tool error rates, time-to-first-token, and request volume. These power dashboards and alerts.

Semantic conventions for GenAI

OTel has emerging semantic conventions for generative AI, so attributes like model name, token usage, and operation type are recorded in a standard way. That means your dashboards and tooling work regardless of which model provider you use.

Practical setup

  1. Instrument the agent loop. Wrap each model call, tool call, and retrieval in a span. Many SDKs and frameworks have OTel instrumentation built in or available.
  2. Record GenAI attributes. Token counts, model, temperature, and finish reason on each model span.
  3. Export through the Collector. Send telemetry to the OpenTelemetry Collector, then fan out to whatever backend you prefer — Grafana/Tempo, Jaeger, or a commercial vendor.
  4. Build the golden dashboards. Latency, cost, token usage, and error rate per agent and per tool.

The payoff

With OTel in place, you stop guessing. You can answer “why was this answer wrong?”, “where is the latency?”, and “what’s driving our token bill?” with data instead of intuition — and because it’s all open standards, you’re never locked into a single observability vendor.

That combination — AI plus open-standards observability — is exactly where we focus. If your agents are a black box today, instrumentation is the fastest way to turn them into something you can operate with confidence.