How it works · 13 of 27 Core
What is AI tracing for LLM apps?
Every step, token and rupee of one answer
AI tracing: An AI trace records each step behind one answer (prompt version, retrieved pages, every model and tool call with its tokens, time and cost), so a team can see why one answer was wrong or slow; message text is personal data, so it is left out or redacted by default.
Loading the animation…
Say it like this A trace is an X-ray of one AI answer: every prompt version, retrieved page, model and tool call, with its tokens, time and cost, so you can see why it went wrong, with personal data blurred before it is stored.
Under the hood — for builders
- Worked example: the trace behind the card's answer
- The card's answer as four spans sharing one trace ID: retrieval, a model call, the refund tool (5.4 s, two tries), a second model call.
- Terms: trace and span
- Trace: every step behind one answer, joined by one ID. Span: one step, with a start, an end and attributes.
- Terms: attribute and content capture
- Attribute: a named fact on a span (model, tokens, prompt version, tool). Content capture: recording the message text itself, off by default.
- How OpenTelemetry names the spans
- A model call is "{gen_ai.operation.name} {gen_ai.request.model}"; a tool call "execute_tool {gen_ai.tool.name}". Tokens go in gen_ai.usage.input_tokens and output_tokens.
- A retry stays inside its step
- "If a transient issue happened and the request was retried automatically, the corresponding span SHOULD cover the duration of the logical operation with all retries."
- Our arithmetic: what the answer cost, and where
- Two calls: 10,800 input tokens (8,000 from cache) and 500 output. At Sonnet 5.5 prices: $0.0114. Output was 4% of tokens, 44% of cost.
- Personal data in traces
- OpenTelemetry: messages "are considered sensitive"; instrumentations "SHOULD NOT capture them by default". Mask numbers, names and IDs before anything is stored.
- Keep the text apart
- For production it recommends to "Store content externally and record references on the spans", so message text gets its own access rules and retention.
- How to run it
- One trace ID from request to every call · prompt version and model ID on model spans · tokens and cost per call · content stored apart, masked, kept briefly.
- Measure it
- Share of answers with a complete trace · slowest span type at the 95th percentile · cost per answer by feature · retries per 1,000 tool calls.
- Watch out
- Sampling so thin the bad answer is missing · retries that fall back to stale data · full prompts anyone can read · cost left to the monthly invoice.
- Sources
- OpenTelemetry GenAI semantic conventions (status Development), read 21 Nov 2026 · Anthropic, Pricing (platform.claude.com), read 21 Nov 2026 · our arithmetic, 21 Nov 2026. The refund story is our example.
What happens in the AI tracing animation, step by step?
- A customer asks where their refund is. The answer says "processed on 10 Nov"; it is still pending at the bank. The log says only "200 OK · 9.0 s": it worked, slowly.
- A trace turns the answer to film and shows its skeleton: one bone per step, in order. The prompt version, two pages, two model calls and one tool.
- Your turn: tap the bone that explains the wrong answer.
- The tool bone: the first try at the refund system timed out after 5.0 seconds; the retry read a cached status from 10 Nov. The model wrote a fluent answer from stale data.
- The prompt bone holds the customer's own words, phone number included. It is blurred before the trace is stored: message text is personal data.
- One answer: 11,300 tokens, 1.1 cents, 9.0 seconds, and the step that broke it. Next: how many bad answers a month is acceptable?
What everyday example explains AI tracing?
An X-ray of one answer. The answer is the patient, the film is the trace, each bone is one step (a span), the labels on the bones are its attributes, and the blurred patch is the personal data the radiographer is not allowed to keep.
Why should a team care about AI tracing?
When a customer or a regulator asks why the AI said something, the team either has the trace or reconstructs a guess; the decisions are what each trace stores, what it must never store, and how long to keep it.