LLM tracing lab
Define the lab goal and success criteria
LLM tracing lab is production work only when one frozen failure can be reproduced, one measurable gate can stop a release, and one operator can safely reverse it.
1Try it yourself
Playground
Trace a failed RAG answer
Open spans in order — find where quality broke before blaming the model.
Before you start
Why this matters
Read this incident aloud: a user reports a wrong answer and the trace must distinguish empty retrieval from a generation defect. In two minutes, write the earliest deterministic check that should fail, the telemetry signal you would inspect, and the action that must not happen automatically. Compare your answer with this chapter's boundary: span attributes contain IDs, counts, model versions, and redacted arguments—not prompts, API keys, or PII.
2Learn the idea
Read
Explain the system and define success
Start by drawing the boundary around OpenTelemetry-style tracing for an embed-retrieve-generate request. The unit under control is not “the model”; it is one repeatable transaction from TraceContext with request_id, release, hashed_user_id, sampled, and baggage to TraceSummary with root_span, child_spans, durations, safe attributes, status, and error_type. In this lab, a user reports a wrong answer and the trace must distinguish empty retrieval from a generation defect. That makes the learning target observable: we can replay the transaction, record the same fields, and decide whether a release is safer than its baseline. The primary decision metric is complete trace ratio and per-span p95 duration. The release rule is at least 0.99 context propagation and no sensitive attributes in exported spans. Those values are deliberately paired: a single average cannot hide a critical subgroup or a security escape.
Write the failure before writing implementation code. Our named reproduction is: the retrieve span reports zero chunks but an uncorrelated model log makes generation look guilty. A useful reproduction contains a frozen input, an expected decision, the release identifier, and enough deterministic dependencies to rerun locally. It must not depend on a live customer, changing clock, or unrestricted provider account. The fixture below is synthetic but shaped like production. Keep it in version control and add a case whenever an incident exposes a missing behavior.
Success has three levels. A request-level assertion explains one example. An aggregate metric catches drift over many examples. An operational rule says who acts and how quickly. Here, llm_trace_complete_ratio records the aggregate, while the request artifact carries a correlation ID. The owner should be able to move from an alert to the exact failing fixture without searching raw prompts. The security boundary is equally explicit: span attributes contain IDs, counts, model versions, and redacted arguments—not prompts, API keys, or PII.
The deliverable is a one-page acceptance contract plus the first red test. Do not tune a model yet; uncertainty about the contract is the bug to remove on this page.
Read
Focused implementation artifact
{"request_id":"req_7b9f2","release":"rag-v12","hashed_user_id":"u_91c","sampled":true,"query":"[REDACTED]"}
Read
Turn the incident into a lab contract
Use the fixture above as the first row of an acceptance table. Add columns for expected decision, prohibited side effect, severity, policy version, and evidence to retain. The failure statement—the retrieve span reports zero chunks but an uncorrelated model log makes generation look guilty—must be falsifiable: a teammate should know exactly which assertion turns red. Write the baseline result before trying a candidate so improvement is comparative rather than anecdotal.
Now calculate complete trace ratio and per-span p95 duration by hand for a three-case toy set: one pass, one ordinary failure, and one critical failure. Apply the published gate, at least 0.99 context propagation and no sensitive attributes in exported spans, without rounding. This exposes whether weighting, critical-case overrides, and empty slices behave as intended. Emit llm_trace_complete_ratio once for the toy run and verify that its labels contain a bounded release and outcome, never fixture text.
The lab is ready only when its fixture is synthetic, its dangerous actions are replaced by recording fakes, and its evidence can be retained safely. The expected incident response is to mark retrieval as the fault domain and link the trace ID in the incident without copying prompt content. Assign that decision to a role, not “the team,” and state which artifact proves recovery.
Continue learning · glossary & guides
-
Is the failure falsifiable from one frozen fixture?
-
Does the gate combine a population metric with critical-case handling?
-
Are owner, evidence, and forbidden action explicit?
-
Local references: Glossary: LLM tracing · How-to: log production calls