← Guides
13 November 2026 · Junaid Khalid · 16 min read

AI Agent Observability: Traces, Metrics and Cost Per Task

AI agent observability is the practice of recording what an AI agent did, step by step, so you can see why it reached a result: every model call, tool call, retry and handoff, with the tokens, latency, cost and errors of each. It turns an agent from a black box with a final answer into a trace you can replay, measure and fix.

The top guides on this query cover traces in depth, and a trace covers one run. Our team runs coding agents on real tickets every day, so we also get asked what a task cost, which model did it, whether it shipped and who checked it. This guide covers traces, metrics and that task-level record. Every attribute name and setting below was checked against the vendor's or the standard's own docs on November 13, 2026.

Key takeaways

What is AI agent observability?

In practice, agent observability means you can open any run and read it top to bottom: the prompt it got, the plan, each model and tool call, and where it stopped. Datadog's definition is short:

"AI agent observability is the process of tracing and analyzing an agentic system's decisions." (Datadog Knowledge Center)

IBM frames it with MELT data: metrics, events, logs and traces. Those signal types predate agents. A web service runs the same code path for the same request. An agent picks its next step at run time, so one request can take three tool calls on Monday and thirty on Tuesday.

Most teams already have some of this. LangChain's State of Agent Engineering report found 89% of teams have some agent observability and 62% have step-level tracing.

LangChain puts the cost of skipping it plainly:

"Without observability, you're left guessing why an agent failed based on its final output alone." (LangChain, Agent observability guide)

How is agent observability different from LLM observability?

LLM observability records single model calls with their prompt, completion, tokens and latency. Agent observability adds the loop around those calls, including the plan, the tools the agent picked, retries, handoffs to other agents or people, and whether the run met its goal.

Question LLM observability Agent observability
Unit One model call One run (many calls and tools)
Typical failure Bad or slow completion Wrong tool, loop, stuck step, bad handoff
Key data Prompt, output, tokens, latency Trace tree, tool arguments and results, step count, spend per run
Evaluation Output quality Goal reached, steps taken, unsafe actions
Who reads it ML engineer Agent developer, on-call, team lead

A third layer sits above both, and none of the top-ranking guides cover it: the unit of work. A coding agent's ticket may span four sessions, two models and a pull request. No single trace holds that.

What should you trace in an AI agent?

Trace every step that can change the outcome: the agent invocation, each model call, each tool call with its arguments and result, each retrieval, each handoff, and each human approval or rejection. Link them under one root span per run so the tree reads top to bottom.

A practical list, in order of value:

  1. Root run span. One per agent invocation, with the agent name, model, conversation or session id, and final status.
  2. Model calls. Model id as requested and as returned, input and output tokens, finish reason, latency.
  3. Tool calls. Tool name, call id, arguments, result or error, duration. Most agent bugs live here.
  4. Retrieval. Query, sources returned, and which ones the agent used.
  5. Handoffs and pauses. Calls to another agent, or waits on a person, with who and why.
  6. Outcome. Did the run do the job? This needs an evaluation or a human check, not just a 200 response.

LangChain's guide adds a useful threshold: once an agent chains two or more tools, or someone other than its author has to debug it, step-level tracing stops being optional.

Which OpenTelemetry attributes cover AI agents?

OpenTelemetry's GenAI semantic conventions define agent spans and a shared set of attributes, so traces from different frameworks look alike in any backend. The agent spans document is marked Status: Development, which means names can still change. The conventions moved out of the main spec into their own repository, semantic-conventions-genai.

The spans you will use most:

Here is a minimal attribute set we would copy into any agent today. Required ones are marked.

Agent run span (invoke_agent)
gen_ai.operation.name        = "invoke_agent"      (required)
gen_ai.provider.name         = "anthropic"         (required on the client invoke_agent span)
gen_ai.agent.name            = "code-reviewer"
gen_ai.agent.id              = "agent-7f2c"
gen_ai.request.model         = "claude-opus-5-5"
gen_ai.conversation.id       = "sess-2026-11-13-0412"
gen_ai.usage.input_tokens    = 182400
gen_ai.usage.output_tokens   = 9100

Tool span (execute_tool)
gen_ai.operation.name        = "execute_tool"
gen_ai.tool.name             = "run_tests"
gen_ai.tool.call.id          = "toolu_01"
gen_ai.tool.type             = "function"

Your own attributes (not in the spec, add them anyway)
work.ticket_ref              = "TD-1234"
work.pr_url                  = "https://github.com/org/repo/pull/88"

The last two lines are ours. The spec has no field for the task a run belongs to, and that is the field you will search by most.

Why do threads and multi-agent runs need their own view?

A thread groups the turns of one conversation or task, and a multi-agent run groups the traces of several agents, so a failure that starts in turn two or in agent B shows up in the same place it began. Single-trace views hide both cases, because each trace looks fine on its own.

What metrics matter for AI agents?

Track a small set per run and roll it up per agent, per model and per task. Datadog suggests treating success rate, unsafe-action rate, maximum steps and maximum spend as service level objectives with failure budgets, which is a good starting frame.

Metric Why it matters Alert when
Task success rate The only metric users feel Drops week over week
Steps per run Loops and wandering show up here first Above your p95
Tokens per run and per task Cost driver, also a loop signal A run uses several times its usual tokens
Cost per completed task What finance and leads ask about Rises without more output
Tool error rate Broken integrations, bad arguments Any spike
Latency per step User wait, timeouts p95 above budget
Human wait time Where agents sit idle waiting on people Grows faster than agent time
Unsafe or blocked actions Guardrail health Any rise

Cost per completed task needs two sources: cost lives in traces, and "completed" lives in your tracker.

How do you get observability for coding agents like Claude Code?

Coding agents run on a developer's machine or in CI, not in your service, so your service's tracing never sees them. Claude Code solves part of this itself: it exports OpenTelemetry metrics and events once you enable telemetry and choose an exporter, sent over the OpenTelemetry Protocol (OTLP). From the Claude Code monitoring docs:

export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317

Langfuse accepts OTLP over HTTP only, not gRPC, so use OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf when pointing Claude Code at it.

The metrics include claude_code.session.count, claude_code.token.usage, claude_code.cost.usage, claude_code.commit.count, claude_code.pull_request.count, claude_code.lines_of_code.count and claude_code.active_time.total. Events include claude_code.tool_result and claude_code.api_request, and the docs describe the cost on that event as "Estimated cost in USD".

Traces are a separate beta signal. Set CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 and OTEL_TRACES_EXPORTER=otlp and Claude Code emits one claude_code.interaction root span per prompt, with claude_code.llm_request and claude_code.tool children. Some attributes follow the GenAI conventions (gen_ai.request.model, gen_ai.tool.call.id), but it sends gen_ai.system rather than gen_ai.provider.name and sets no gen_ai.usage.* attributes, so expect a mapping step in your collector.

That gives you sessions, tokens and dollars per developer. It does not tell you which ticket the session served or whether the change was accepted. You add that link yourself, on the exporter or in the tracker where the work lives. To tag a session with its ticket, set this before launching the agent:

export OTEL_RESOURCE_ATTRIBUTES="work.ticket_ref=TD-1234"

It applies per session, not per prompt, and adds metric cardinality unless you set OTEL_METRICS_INCLUDE_RESOURCE_ATTRIBUTES=false. Our guide to running tasks in Claude Code covers how the agent picks up and reports on tickets.

Which AI agent observability tools should you consider?

Start with the layer you are missing. If you cannot debug a single run, get a tracing tool. If you cannot see trends, use your metrics platform. If nobody can say what a task cost, fix the task record. Every tracing tool below works with OpenTelemetry, so you can switch backends later without re-instrumenting.

Tool Layer Source model OpenTelemetry Best for
LangSmith Traces, evals Commercial Accepts OTel traces LangChain and LangGraph teams
Langfuse Traces, evals, prompts MIT core, enterprise folder separate Native OTLP ingest Self-hosting with an open core
Arize Phoenix Traces, evals Elastic License 2.0 Built on OTel Local debugging and evals
OpenLLMetry Instrumentation Apache 2.0 Emits OTel Adding GenAI spans to any backend
Datadog LLM Observability Traces, metrics, SLOs Commercial OTLP via Agent, Collector exporter or DDOT Teams already on Datadog
Microsoft Foundry observability Evals, tracing Commercial OTel based Agents built on Azure
Work tracker with AI work records Task record, cost per task, proof Varies Not a tracing tool Coding agents doing ticketed work

If you are asking "what's the best tool for AI observability", our pick per reader:

Where does the task record fit in observability?

The task record is the top layer: one entry per unit of work that holds every session, model, token count, cost, file, commit and pull request behind it, plus the proof that it was done. You read a trace to debug a run and the task record to see what a piece of work cost and where it landed.

This is the gap we built Jenzo for. It is a ticket tracker where agents open, update and close tickets themselves over the Model Context Protocol (MCP) or the API. On each ticket, the agent runs its own work clock, separate from the person's timer, and reports input and output tokens. The work trail logs files touched, repo, branch, PR URL, commits, cost in USD, minutes and model. A ticket cannot close without proof: a link, or a closing report a quick judge model checks for substance.

Whatever tool holds it, a task record needs these fields:

Task record (one per ticket, many sessions)
ticket_ref, agent, model, minutes, input_tokens, output_tokens,
cost_usd, repo, branch, files[], commits[], pr_url, closing_proof

You still want a tracing tool next to it. The ticket is where you look up what a feature cost in agent time across four sessions. For the wider picture of running many agents, see our guide to an AI agent management platform.

What did our own agent data teach us about observability?

We pulled our team's agent clock records on November 13, 2026: 125 AI work sessions on 93 tickets, 3,139 active minutes in total. The median session ran 11 minutes. The longest hit the 4-hour cap.

Three lessons came straight out of the data:

We now ask every agent to state its model id and ticket ref before the clock starts, because 12 of 125 sessions had no model.

What are the best practices for AI agent observability?

Instrument with open standards, trace every tool call, measure outcomes and not only latency, keep cost per task visible, and put humans where the risk is. Microsoft's five practices for Azure agents are a sound outline: pick models with benchmarks, evaluate continuously, put evaluations in CI/CD, red team before production, and monitor in production with tracing, evaluations and alerts.

Copy this checklist into your agent's README:

AI agent observability checklist
[ ] One root span per run, with agent name, model id and session id
[ ] execute_tool span for every tool call, arguments and result included
[ ] Input and output tokens on every model span
[ ] Ticket or task id attached to every run (custom attribute)
[ ] Telemetry exported over OTLP, not a vendor-only SDK
[ ] OTel GenAI semconv version pinned (spec is still Development)
[ ] Prompts and outputs redacted or sampled before export
[ ] Alerts on steps per run, token spikes and tool error rate
[ ] Eval set of 20+ real tasks, run in CI on every prompt or model change
[ ] Failed production traces added to the eval set each week
[ ] Human approval logged for risky actions, with who and when
[ ] Agent clocks stop on idle and cap, so stale sessions do not skew averages
[ ] Every closed task links its proof: PR, commit or report

The eval lines close the loop LangChain describes: every failed production trace becomes a test case, and the next prompt or model change has to pass it. Without that step, traces explain failures but never prevent the next one.

For the approval line, our guide to human in the loop AI shows which agent actions need a person and how to record the decision.

What are the challenges of observing AI agents?

The main challenges are volume, privacy, cost attribution and moving standards. Agents produce long traces with full prompts and tool outputs, which raises storage cost and the risk of logging secrets or customer data. Cost is spread across sessions and tools, so per-task numbers need a join you build yourself.

Practical answers:

FAQ

What is observability in an AI agent?

Observability in an AI agent is the record of its steps, linked into a trace: inputs, plans, model calls, tool calls, results and handoffs, with tokens, latency, cost and errors on each. It lets you explain why the agent produced a result and find the exact step that failed, instead of guessing from the final answer.

What's the best tool for AI observability?

Pick by stack. LangGraph teams do well with LangSmith, teams that self-host pick Langfuse, and teams on Datadog use its LLM Observability. For coding agents working tickets, send their beta OTLP traces to one of these, their metrics to your metrics platform, and keep cost per task in your tracker.

What are the four pillars of observability?

The four pillars are metrics, events, logs and traces, often shortened to MELT. For agents, traces matter most, because they show the order of model and tool calls. Metrics cover tokens, cost and latency across runs. Events mark tool failures and handoffs, and logs hold prompts and decisions.

How can AI be used in observability?

AI helps observability in two ways. It can read traces and logs for you, for example by summarizing a failed run or answering questions in plain language about many traces. It can also act as a judge, scoring agent outputs in evaluations. Keep a human check on any judge that gates releases.

Is there open source AI agent observability?

Yes. Langfuse is MIT licensed outside its enterprise folders, OpenLLMetry and Opik are Apache 2.0, and Arize Phoenix is source available under the Elastic License 2.0. All of them work with OpenTelemetry, so you can start self-hosted and move to a managed backend later without rewriting instrumentation.

Why is observability called o11y?

O11y is a numeronym: the letter o, then 11 for the eleven letters between the first and last letters, then y. It follows the same pattern as k8s for Kubernetes and i18n for internationalization. Engineers use it as shorthand in tool names, channel names and conference talks.

Is Grafana an observability tool?

Yes. Grafana is an open source dashboarding and observability tool that visualizes metrics, logs and traces from many backends, including Prometheus, Loki and Tempo. For agents, you can send OpenTelemetry data from Claude Code or your framework to a collector and chart tokens, cost and errors in Grafana.

From our own experience

We assumed a tracing tool would answer our questions about agents. It answered how a run behaved, but not what a task cost or whether it shipped. What changed things was small: every agent states its model and ticket when it starts, stops on idle, and closes only with proof. The surprise was how much of our missing data traced back to agents skipping a single field.

Let your agents keep the board.

Claude Code, Codex and Cursor open their own tickets, log hours and tokens, and close them with the commit.

Connect your agent