Tracing and Observability for AI Systems › The Six Trace Families
Language AI HandbookAll chapters Different parts of a compound system warrant different trace schemas, because the questions you ask of each differ. We can group them into six families. In practice one trace contains spans from several families: the root chain span has llm and retriever children.
It helps to think of each family as answering a distinct diagnostic question rather than as a distinct storage table. When something goes wrong, an engineer silently asks a sequence of questions, and each family is the structured record that lets one of those questions be answered quickly. Reading the families in order of a typical debugging session (what was asked, what was retrieved, what was called, how slow, how expensive, how good) makes the design motivation concrete.
Prompt traces
Record the model and template revision, decoding parameters that affect the request, and available token counts. Rendered prompts and completions can contain user text, retrieval results, or system instructions. Capture content only under an explicit access and retention policy. A template revision or protected reference often provides the first lead without copying the text into routine traces.
Trace the template version and any approved reference to the rendered prompt separately. The template identifies which instructions and placeholders were configured. The actual model input depends on the rendered variables, their message roles, and the retrieved data available at request time. A request can record enough version information to identify a template change without storing the original user text. Evaluation Harnesses and Reproducibility
Retrieval traces
For a retriever span, record the protected query or embedding reference, the index and embedding-model versions, the requested candidate count, and the returned document IDs and scores. Include scores after fusion or reranking and record the retrieval settings that produced them. The resulting list shows each returned document’s rank. A label for the top result alone cannot establish recall.
An approved set of document IDs and scores is enough to compare ranked lists against relevance labels. Recall at divides relevant items found in the first results by the total number of relevant items. Precision at divides by for a list of at least results. Rank comes from the order of the returned list, and a trace without relevance labels cannot establish recall.
Tool traces
A tool span can record the approved tool name and version, authorization outcome, execution status, and latency. An operation that was attempted, denied, or completed needs a distinct outcome. Keep credentials and customer records out of routine tool telemetry. A controlled evidence capture may hold additional material when an authorized investigation requires it.
Record whether each approved field came from a model proposal, a validated request parameter, or a tool response. Preserve source and trust-boundary information without exposing the argument or response body.
Latency traces
Latency is a derived view of span timings. A complete request span gives elapsed time, and span groups show which operations consumed time. Computing a critical path also requires dependency information, such as which result a join waits for. Latency Optimization covers ways to change those timings.
A p95 alert tells you users are waiting. Inspect traces from the affected route to see whether the retriever, a tool call, or a second generation is a candidate contributor. Compare against traces from unaffected requests before drawing a conclusion.
Cost traces
Derive per-span estimates from the billing units you observed and the price table in effect. The partial sum covers only operations with observed usage and a known price. Preserve the price-table version so you can distinguish changes in rates from changes in usage. Cost Management
For example, if estimated cost rises on one route, compare prompt length, output length, retry count, model version and rate changes. The trace can expose the contributing operation when those fields are available. Reconcile totals against billing records where actual charges matter.
Quality traces
A quality trace attaches an evaluation signal to a span or trace. Examples include recall at a fixed cutoff, a groundedness score from a judge, a user rating, and a task-success flag. If scoring every request costs too much, use a sampling plan and record which requests received which kind of score. LLM-as-Judge covers judge design.
The specific value of quality traces is that they close the loop between "bad" and "why." A user thumbs-down is a signal with no explanation; when it is linked to a specific generation span, whose inputs are traceable to a specific retrieval span, whose IDs you can inspect offline, the signal becomes a lead. Group the bad traces by the prompt version, index version, or route that appears in their attributes, and you have a hypothesis about the cause without ever having manually read a single request.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!