Tracing
Recording the full execution path of an LLM call (retrieval, generation, tool calls) for debugging.
Step 1 of 5
Root span
The whole request is recorded as one span. In this example it took 4.2 seconds, which is too slow.
Each stage becomes a span with its own latency, so the bottleneck is visible.
Simple explanation
A trace is a record of every step your AI system took: what was retrieved, what prompt was sent, what the model returned, how long each step took. Without traces, production AI is a black box.
Engineering explanation
Tracing uses OpenTelemetry spans: root span (request) → child spans (retrieve, rerank, generate, tool_call). Each span has attributes (model, token_count, cost, latency, scores). Export to LangSmith, Honeycomb, Jaeger. Production: keep every error trace, sample a small share of successes, build dashboards on P50/P95/P99 latency + cost + quality.
Example
Slow query (4.2s) → trace shows retrieve=3.4s (bottleneck) → fix: rebuild HNSW index.
When to use it
Every production LLM system. Non-negotiable for debugging, cost attribution and quality monitoring.
Common misconception
Tracing is NOT optional. 'I'll add it later' means you can't debug the first production incident. Add tracing from day one.