What Is Tracing for LLM Apps?
What a trace and a span are, what gets recorded, and how to use one to find why an AI answer was wrong or slow, for your AI interview.
In short
Tracing for LLM apps records each step of one request, such as each model call, tool call and document search, with its inputs, outputs and timing. The steps for one request form a trace, which shows why an answer was wrong or slow.
10 min readIntermediateVery common · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
Tracing is a logbook for one AI request. It records each step: every model call, tool call and document search, with what went in, what came out and how long it took. Those steps form a trace. When a claim takes 33 seconds, or an answer goes wrong, the trace shows which step caused it. I also keep personal data out of traces, because they can hold user prompts.
An AI app works in steps. It may search a document, call a model, call a tool such as a policy lookup, then call the model again to write the reply. Tracing records each step as it happens. Each record keeps what went in, what came out and how long it took. LangSmith calls each step a run, and the steps for one request together form a trace.
Take a claims triage agent at a mid-size insurer that suddenly takes 33 seconds on one claim. The final text looks fine, so it tells me nothing. The trace shows a policy lookup timing out after 30 seconds, then retrying. That is where the time went. The fix is a shorter timeout with a fallback path, and the model stays as it is.
Tracing has a privacy cost. Traces can capture user prompts and responses, so I redact personal fields before they are logged and limit who can read the traces. Extra pricing can also apply, so I keep the detail that helps debugging and set how long it stays.
Tracing shows what happened. Whether an answer was right needs an evaluation, so I pair traces with evaluations that score the answers.
What is tracing, in plain words?
A trace is a logbook for one AI request. The AI is usually a large language model (LLM), the kind of model that writes and reads text. The trace lists each step the app took to answer it: every model call, every tool it used, every document it searched, and how long each step took.
Think of the chart a hospital nurse keeps for one patient. Each test, drug and visit goes on it with a time, so anyone can see what happened and in what order. Tracing does the same for an AI request.
Here is a realistic case. A claims triage agent at a mid-size insurer takes 33 seconds to handle one claim. The final text looks fine, so the text alone tells you nothing. The trace shows where those seconds went.
Key words
- Trace
- All the recorded steps for one request, grouped under one trace ID.
- Span
- One timed step inside a trace, such as one model call.
- Run
- LangSmith's name for a step. It works like a span.
- Tool call
- The model asking your code to run a function, such as a policy lookup.
What does a trace record?
Microsoft's Foundry docs say tracing records information such as the user's inputs and prompts, the agent and model inputs and outputs, and the tool calls and intermediate steps.
Inputs and outputs
What went into each model call and tool call, and what came back.
Tool calls
Which tools ran, with what arguments, and what they returned.
Timing
When each step started and ended, and how long it took.
Cost and errors
Token usage (the pieces of text the model counted) and any errors.
That detail is also the risk, covered further down. A trace with a full prompt is a copy of the user's data.
How do runs, spans and traces fit together?
A step is called a run in LangSmith and a span in OpenTelemetry, the standards that Microsoft says its tracing is built on. A trace groups the steps for one request. LangSmith and Microsoft put it like this:
“A trace is a collection of runs for a single operation.”
LangSmith
“Distributed tracing captures the execution flow of AI applications, providing visibility into LLM calls, tool invocations, agent decisions, and inter-service dependencies.”
Microsoft
How one request becomes one trace
Customer's claim
one request to the agent
Claims agent
calls a model and tools
Recorded as spans
Model call
reads the claim, plans
Policy lookup
timed out, then retried
Model call
writes the reply
One trace
every step, with timings
- 1The claim reaches the agent as one request.
- 2The agent records each step it takes as a span.
- 3All the spans are saved together as one trace.
Here is the same idea in a few lines of plain Python. Each step is a span, and a span nests under the step that called it.
# A tiny tracer: each step is a span, and a span nests under the step that called it.
# The timings are made-up numbers, so the output is the same on every run.
spans = []
def span(name, ms, parent=None):
spans.append({"name": name, "ms": ms, "parent": parent})
return len(spans) - 1
def show(i, depth=0):
s = spans[i]
print(" " * depth + f"{s['name']} ({s['ms']} ms)")
for j, child in enumerate(spans):
if child["parent"] == i:
show(j, depth + 1)
run = span("claim_agent", 33050)
span("model_call: plan the check", 850, run)
tool = span("tool: policy_lookup", 31000, run)
span("api_timeout", 30000, tool)
span("retry", 1000, tool)
span("model_call: write reply", 1200, run)
show(run)Output
claim_agent (33050 ms)
model_call: plan the check (850 ms)
tool: policy_lookup (31000 ms)
api_timeout (30000 ms)
retry (1000 ms)
model_call: write reply (1200 ms)Read the output as a tree. The policy lookup has a 30-second timeout and a 1-second retry under it, so the tool is where the time went. OpenAI's Agents SDK docs describe the same shape: a trace is an end-to-end operation made of spans, and each span has a start and an end time.
Tip
If asked to define a trace, say what it is and give one example from a real app, such as a claim that took too long. Then say spans are the steps inside it.
What does tracing cost you, and what must you protect?
Microsoft's Foundry docs say tracing is off by default, and that it can capture personal data, including user prompts and responses. Once you turn it on, traces can hold your users' data.
OpenAI's Agents SDK has tracing enabled by default. Its docs say the spans for model calls and function calls store inputs and outputs, and that these may contain sensitive data, so you can disable capturing that data.
- Too little
Only the final reply
You cannot see which step failed, or why.
- Right amount
Every step, timed
Each step has timing and inputs, with personal fields redacted and read access limited.
Microsoft says to redact or minimise personal data before it is logged, and to apply access controls and retention policies to trace data. It also notes that extra pricing might apply for Azure Monitor App Insights, its logging service.
How would you find out why a claim took 33 seconds?
Start with the trace for that one claim. Then follow the steps.
From a slow answer to a fix
Claim takes 33 s
final text looks fine
What the trace shows
Model call: plan
0.85 s, plans the check
Policy lookup
30 s timeout, then a retry
Shorter timeout
plus a fallback path
Claim done, faster
same model, shorter wait
- 1Open the trace for that one claim.
- 2The policy lookup stands out, and its timeout explains the wait.
- 3Shorten the timeout and add a fallback, then test the same claim.
- 1
Find the trace by its ID
Every run in one trace is tied to one trace ID, so a single lookup gets the whole path.
- 2
Sort by time
Look for the widest step. Here the policy lookup took 31 seconds, far more than the 850 ms model call.
- 3
Check its children
The 30-second timeout and the 1-second retry sit under the tool, so the fault is in the tool, not the model.
- 4
Fix and test again
Shorten the timeout, add a fallback path, then run the same claim again and read the new trace.
What does the interviewer want to hear?
A strong answer covers
- A plain definition: a trace is the record of one request, made of timed steps.
- Trace, span and run, and how they nest.
- What gets recorded: inputs, outputs, tool calls and timings.
- Why it beats reading the final answer: you see which step failed.
- The privacy cost: traces can hold personal data, so redact and limit access.
- Tracing shows what happened. Evaluation scores whether it was right.
Common traps
Trap"Reading the final answer is enough."
BetterThe final answer hides the failing step. A trace shows each model call, tool call and search in order.
Trap"Tracing is just logging, so turn on everything."
BetterTraces can hold personal data. Capture what you need, redact personal fields, and limit who can read them.
Trap"A trace shows whether the answer is correct."
BetterA trace shows what happened. Whether an answer is right needs an evaluation that scores it.
Can you spot the problem in a trace?
Spot the risk
Your support bot saves every trace. Which span needs fixing before launch?
Quick check
A bank's fee bot quoted an old card fee. Which record shows why?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
Learn it in depth
Last updated on 26 November 2026
Building an AI app you need to debug in production?
I design and build AI products and agents, and the system behind them, including tracing so problems can be found. Book a short call and tell me what you need.