Tapnod.All articles

Monitoring ยท 2026-11-26

Agent Observability: An Implementation Guide

How to implement agent observability step by step: instrument runs and tools, collect with OpenTelemetry, pick a backend, build three views and act on them.

The short answer

Implementing agent observability comes down to four stages:

  1. Instrument: emit a span for each agent run, model call, tool call and human request, with consistent attributes.
  2. Collect: send telemetry through an OpenTelemetry collector or a platform SDK, with sampling and redaction.
  3. Store and view: use a trace platform or observability backend, and build three views: run detail, fleet health and cost.
  4. Act: alert on errors, silence, cost spikes and long human waits, and route alerts to owners.

Most teams get stages 1 to 3 working in a day. Stage 4 is where observability starts paying off.

Pipeline from instrumented agents through an OpenTelemetry collector to traces, dashboards and alerts

"agent observability" gets about 480 US searches a month at a keyword difficulty of 36 (Semrush, November 2026). It's the practical sibling of AI agent observability: less what, more how.

Stage 1: instrument

Start with four span types:

Span Key attributes
Agent run (invoke_agent) agent name, version, task ID, requester
Model call (chat) model, input and output tokens, latency
Tool call (execute_tool) tool name, call ID, status, duration
Human request request type, assignee, wait time, decision

Framework integrations cover the first three for many stacks: LangChain, LangGraph, the OpenAI Agents SDK, CrewAI and others ship callbacks or OpenTelemetry instrumentation, directly or through libraries like OpenLLMetry. Human requests usually need a few lines of your own.

from opentelemetry import trace
tracer = trace.get_tracer("agents")

def request_approval(run, action):
    with tracer.start_as_current_span("human_request") as span:
        span.set_attribute("gen_ai.agent.name", run.agent)
        span.set_attribute("hitl.type", "approval")
        span.set_attribute("hitl.assignee", action.owner)
        answer = inbox.request_and_wait(action)          # or resume later
        span.set_attribute("hitl.decision", answer.choice)
        span.set_attribute("hitl.wait_seconds", answer.wait_seconds)
        return answer

The hitl.* names are our own; OpenTelemetry doesn't define human request attributes yet.

Stage 2: collect

An OpenTelemetry collector between agents and backends gives you one place to sample, redact and route:

processors:
  attributes/redact:
    actions:
      - key: gen_ai.input.messages
        action: delete
  probabilistic_sampler:
    sampling_percentage: 20
exporters:
  otlphttp/traces:
    endpoint: https://your-trace-backend.example.com
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [attributes/redact, probabilistic_sampler]
      exporters: [otlphttp/traces]

Keep all error traces even when sampling successes; tail-based sampling in the collector can do that. Redacting in the collector, rather than in each agent, means one change covers every agent.

Stage 3: store and view

Pick a backend that accepts what you emit. Langfuse, LangSmith, Arize Phoenix and others accept OpenTelemetry data; general platforms like Datadog and Grafana do too. Then build three views:

View Shows Used by
Run detail The trace tree of one run, with inputs and outputs Engineers debugging
Fleet health Every agent: status, last contact, error rate, waiting decisions Owners and leads, daily
Cost Spend by agent, model and day Budget owners, weekly

Most trace platforms give you run detail out of the box. Fleet health usually needs extra work, because it depends on agents that stopped sending data.

Stage 4: act

Alert Condition Route to
Run failed Error status on agent run Agent owner
Silent agent No contact for 3x its normal interval Agent owner
Cost spike Daily spend over 2x 7-day average Budget owner
Loop Steps per run over a limit Agent owner
Long human wait Approval pending over its timeout Assignee, then backup

Send alerts where owners will see them, ideally the same place their agents' questions arrive, so they don't check three tools.

Coding agents

Coding agents like Claude Code and Codex aren't code you instrument yourself, but they export telemetry. Claude Code can export OpenTelemetry metrics such as cost and token usage, and both tools support hooks or notify commands you can use to report status and completion. Combine those with an inbox that tracks last contact, and coding agents show up in fleet health alongside your own agents. See Claude Code usage dashboard.

Naming and attributes

Consistency matters more than completeness. Agree on a small set of attributes and use them everywhere:

Attribute Example Why
Agent name release-agent Group by agent
Agent version 2026-11-20.3 Compare changes
Environment prod Separate test noise
Task ID T-8812 Link to the business object
Owner platform-team Route alerts

Put these on the root span and propagate them, so every child span can be filtered the same way. Teams that skip this end up with traces they can't group, and dashboards that can't answer "which agent".

Choosing a backend

Pick by what else you need beyond traces. If you want evaluations and prompt management in one place, an LLM-focused platform fits. If you already run Grafana or Datadog for the rest of your systems, sending agent traces there keeps one place for on-call. If data must stay in your network, choose something you can self-host. Because you emit OpenTelemetry, changing later is a configuration change rather than a rewrite.

Common pitfalls

  • Logging full prompts everywhere. Costly and risky; redact or sample.
  • No agent version attribute. You can't compare before and after a prompt change.
  • Ignoring silence. Dashboards built only from received data miss dead agents.
  • Alerts without owners. Every alert needs a named person.
  • Too many dashboards. Three good views beat fifteen half-used ones.

Testing your observability

Break things on purpose in a test environment. Revoke a tool's token, kill an agent mid-run, force a loop, and leave an approval unanswered. For each, check that the trace shows it clearly, the right alert fires, and it reaches the right person. Observability that has never seen a failure will miss the first real one.

Rollout plan

Week Goal
1 Instrument one agent; run detail view working
2 Add cost metrics and the cost view
3 Add human request spans and last-contact tracking
4 Turn on alerts with owners; review noise and tune

A worked example

Picture a team with a LangGraph support agent and a custom research agent. They add OpenLLMetry to both, route through a collector that drops message content in production, and export to a trace platform. Human approvals are wrapped in spans with wait time. A small job checks each agent's last span and posts silence alerts to the owner's inbox. In week four, the first silence alert catches a research agent stuck on an expired API key that never threw an error.

Key takeaways

  • Instrument runs, model calls, tool calls and human requests.
  • Use an OpenTelemetry collector for sampling, redaction and routing.
  • Build three views: run detail, fleet health and cost.
  • Alerts on errors, silence, cost, loops and long waits, each with an owner.

FAQ

How do I add observability to an AI agent?

Instrument runs, model calls and tool calls with your framework's integration or OpenTelemetry, send data to a trace backend, then add dashboards and alerts.

Which spans should an agent emit?

At least an agent run span, model call spans, tool call spans and spans for human requests, with agent name and version on each.

Can I use OpenTelemetry for agent observability?

Yes. OpenTelemetry's GenAI conventions define agent, model and tool spans, and many backends accept them, though the conventions are still in development.

How do I detect an agent that stopped running?

Track the time since each agent's last span or check-in, and alert when it exceeds the normal interval.

Where Tapnod fits

Tapnod covers fleet health without extra dashboards: last contact, active agents, waiting decisions, results and errors in one inbox. Try it free.

One inbox for every agent's questions

Approve plans and answer agents from web or phone. Start free.

Start free

Related articles