1What we are demystifying
Tracking and performance tracking, defined.
This page answers one question: how do you track what a production agent does, and how well it performs?
Tracking means a record of every step of every request: which model call, which tool, in what order, and what came back. Performance tracking adds the numbers to that record: how long each step took, how many tokens it used, and whether it failed.
2Why it matters
An agent answer is several steps.
A chatbot answer is one model call. An agent's answer is several: it may classify the question, call a tool, then call the model again with the result. When a user says "it was slow" or "it got it wrong", you need to know which of those steps did it.
| When someone asks | You need to know |
|---|---|
| "Why was it slow?" | Time per step, to find the one that dominated |
| "Why did this cost so much?" | Tokens per model call |
| "Why did it say that?" | Which route and tool it took, and what the tool returned |
| "Is it getting worse?" | The same numbers across many requests, over time |
3What you can use
Logging, platforms, cloud monitoring, OpenTelemetry.
| Option | What it is | Cost and set-up |
|---|---|---|
| Python logging | Built into Python. Your code writes events to a screen, file or log service | Free, already installed |
| A tracing platform | A hosted product that records each request as a tree of timed steps and gives you a UI to search it. LangSmith, Langfuse, Arize and Braintrust are examples | An account and an SDK. Free tiers with limits are common; check each one |
| Your cloud provider's monitoring | Logs, metrics and traces inside the platform you already deploy on | Usually billed by volume |
| OpenTelemetry | An open standard for producing this data, which many of the tools above can receive | Free and open source; you still need somewhere to send it |
These are not exclusive. OpenTelemetry is a way of producing the data; the other three are places it can go. Many teams use logging and one other option side by side.
4Why compare these two
Basic and free versus a full platform.
This page compares Python logging and LangSmith tracing, because they sit at the two ends of the range.
- Python logging is the most basic option: free, in every Python install, no account.
- LangSmith is a full platform built for LLM apps: automatic step trees, token counts and a UI.
Most people start with one and wonder whether they need the other. Seeing the same agent tracked both ways answers that better than a feature list. LangSmith stands in for tracing platforms in general here. I chose it because its tracing for LangChain and LangGraph code is automatic, not because I have ranked it against the others.
5The example agent
Three steps, made-up numbers.
Here is the agent we will track. It answers "Where is my order?" in three steps: a model call to classify the question, a tool call to look up the order, and a model call to write the answer. There is no real model; each step returns fixed, made-up timings and token counts so the results are repeatable.
6Tracked with Python logging
JSON lines, then a summary you write.
With logging, you decide what to record and write it yourself. One JSON line per step, each stamped with the same request id. (How the logger, levels and JSON formatter work is covered in Logging for AI apps.)
import json, logging, sys
log = logging.getLogger("support_agent"); log.handlers = []
log.addHandler(logging.StreamHandler(sys.stdout)); log.setLevel(logging.INFO)
def step(request_id, name, ms, tokens=0):
log.info(json.dumps({"request_id": request_id, "step": name, "ms": ms, "tokens": tokens}))
step("req-7f3a", "classify", 420, 101)
step("req-7f3a", "get_order_status", 210)
step("req-7f3a", "answer", 1350, 452){"request_id": "req-7f3a", "step": "classify", "ms": 420, "tokens": 101}
{"request_id": "req-7f3a", "step": "get_order_status", "ms": 210, "tokens": 0}
{"request_id": "req-7f3a", "step": "answer", "ms": 1350, "tokens": 452}7Tracked with LangSmith
Decorators, and the trace they produce.
With LangSmith, you attach a small decorator, @traceable, to each function you want recorded. LangChain and LangGraph code is traced without it. Nothing else in the function changes.
Set an API key and turn tracing on, and every call to handle becomes one trace: the parent, with the model and tool calls nested underneath. (Shape from LangSmith's docs; I have no account, so this was not run.)
The diagram uses this page's made-up numbers; it is a sketch of the shape, not a screenshot of LangSmith.
8Side by side
Cost, set-up, views and fit.
| Python logging | LangSmith tracing | |
|---|---|---|
| Cost | Free | Free tier with limits, then paid |
| Set-up | Nothing to install | Account, API key, SDK |
| What it records | What you write | Each marked function: inputs, outputs, timing |
| Steps of one request | Lines sharing a request id | A nested tree |
| Tokens per step | If you log them | Shown for model runs |
| Viewing it | Your log tool, or code you write | A UI built for agents |
| Where data goes | Wherever you send it | A hosted service |
| Best for | Every app, from day one | Debugging multi-step requests one at a time |
9Use both, safely
One id across both, and what not to record.
Using both is common, and they work better together. Put the same id in your log lines and on the trace, as a tag or metadata, and you can move from a strange log line to its full trace and back. If you trace with OpenTelemetry, a small logging filter can copy the trace id onto every log record for you.
10Check yourself
Short questions, a try-it and one line to remember.
What is the difference between tracking and performance tracking?
Tracking records which steps ran and what they returned. Performance tracking adds time, tokens and failures for each step.
Why does an agent need more than a chatbot?
Each answer is several steps, so you need to know which step was slow, costly or wrong.
What do you have to build yourself with Python logging?
The fields, the timing and every summary or view, such as total time and slowest step per request.
When is a tracing platform worth adding?
When you regularly debug single requests across many steps and need the step tree and tokens per step without writing that code.
How do you use both together?
Put the same request or trace id in your logs and on the trace.