AI Agent Observability and Tracing in Production
Why logging inputs and outputs isn't enough for AI agents in production — and how trace-level observability catches failures evals and logs miss.

An AI agent that works in testing and then behaves strangely in production is one of the most common — and most frustrating — problems in building agent systems. The frustrating part isn't that it fails; it's that without the right visibility, you often can't tell why it failed, because a normal application log doesn't capture what an agent actually did on the way to its answer. This is what observability and tracing solve, and they're different from both traditional logging and from the evaluation techniques covered in our guide on AI agent evaluation and testing.
Why Normal Logging Isn't Enough
A typical web application log tells you a request came in, what handler processed it, and what response went out. That's sufficient because the logic in between is usually deterministic and short.
An AI agent is neither. A single user request might trigger several LLM calls, multiple tool invocations, and branching decisions based on what the model decides to do next — and the same input can take a different path on a different run. If all you're logging is "request in, response out," you have no way to answer the question that actually matters when something goes wrong: what did the agent actually do, and where did it go wrong?
What a Trace Actually Looks Like
Tracing represents a single agent run as a tree of spans — timestamped, nested units of work:
- The root span — the overall agent run, from the initial user request to the final response
- LLM call spans — each call to the model, including the exact prompt sent, the response received, token counts, and latency
- Tool call spans — each function/tool invocation, with its arguments, return value, and duration
- Nested spans — a tool call that itself makes an LLM call (common in multi-step or multi-agent systems) nests inside its parent
Viewed as a tree, a trace lets you reconstruct exactly what happened for any single request: which tools were called, in what order, with what inputs, and how the model's reasoning moved from the original question to the final answer.
What to Track on Every Span
Three metrics matter far more than the rest:
- Latency — how long each step took, so you can find the actual bottleneck instead of guessing whether it's the model, a tool, or a downstream API
- Token and cost usage — attributed per span, so you can see exactly which step of an agent's process is driving cost, not just a total bill at the end of the month
- Outcome status — did this span succeed, fail, or return something that looks off (a tool error, an empty result, a malformed response)
Tracked consistently, these three answer the questions that actually come up in practice: is this agent slow, is it expensive, and did it work.
The Silent Failure Problem
The hardest failure mode to catch in an agent system isn't a crash — it's a confident, well-formatted, entirely wrong answer. Nothing throws an error. No span fails. The agent just produces output that looks correct and isn't.
This is exactly where evaluation and observability need to work together rather than substitute for each other. Evals (covered in depth in our evaluation and testing guide) catch this before deployment, against a known set of test cases with known correct answers. Tracing catches it in production, where you don't have a known-correct answer to compare against — which is why production tracing often relies on secondary signals: user feedback, downstream corrections, or a lightweight LLM-as-judge pass sampled across live traffic.
What to Alert On
Uptime monitoring alone gives false confidence with agent systems, since an agent can be "up" and responding while quietly producing bad output. More useful signals:
- Tool error rate — a spike almost always means an upstream API, database, or integration broke, and it's usually the fastest way to catch an outage before users report it
- Latency percentiles, not just averages — a handful of very slow runs (a model retry, a hung tool call) can hide inside a healthy-looking average
- Cost per request — a sudden jump often signals a prompt regression, an agent stuck in a retry loop, or a tool returning far more data than expected
Setting alert thresholds on these three, rather than just "is the endpoint responding," catches the failure modes that actually happen in agent systems.
Getting Started Without Overbuilding It
You don't need a full observability platform on day one. A reasonable progression:
- Structured logging first — log each LLM call and tool call as a structured event with a shared request ID, even if it's just to your existing logging pipeline
- Add span-level timing and token counts — wrap LLM and tool calls with timing and cost tracking, tagged with the same request ID
- Move to a dedicated tracing tool once volume justifies it — once you're debugging production issues weekly rather than rarely, a purpose-built LLM tracing tool (rather than raw logs) pays for itself in debugging time saved
Key Takeaways
AI agents fail in ways that traditional application logging wasn't built to capture, because the interesting behavior — which tools got called, in what order, with what reasoning — happens inside the request, not just at its boundaries. Trace-level observability, tracking latency, cost, and outcome on every span, turns "the agent did something weird" into "here's exactly what happened and why." Combined with the evaluation practices in our evals guide, it closes the loop between catching failures before deployment and catching them in the wild.
If you're building or scaling an agent system and want a second opinion on your observability setup, let's talk it through.






