LLM tracing lab
Handle failures and retries
When missing parent context → orphan spans, cannot join retrieve to answer, the system must degrade on purpose without widening blast radius.
1Learn the idea
Read
Classify and bound retries
Map failure classes for POST /v1/support/answer: retryable vs fatal vs needs-human. Retries need budgets, jitter, and idempotency rules aligned to every span carries trace_id + redacted attrs; prompts sampled ≤ 1%. The chapter’s signature failure — missing parent context → orphan spans, cannot join retrieve to answer — must take a deliberate branch, not a generic catch-all.
Read
Containment path
Implement the degrade/rollback/refuse behavior on-call engineer debugging a slow groundedness miss needs when TRACE-ORPHAN-441 repeats. Prefer scoped controls (one flag, one weight, one tenant, one secret version) over fleet-wide restarts. Preserve evidence; do not delete logs to “clean the demo.”
Read
Implementation artifact
if not get_current_span().is_recording():
metrics.increment("trace_context_missing_total")
Read
Verify harm reduction
After containment, check trace_completeness ≥ 0.99 and p95_end_to_end_ms ≤ 2500 moves in the safe direction and watch for retry amplification. Write the stop condition that ends the incident response for this lab.
Read
Stage depth
Chaos note: inject only one fault class at a time and restore fixtures after. Watch for dual failures — dependency down and retry amplifier — which is how missing parent context → orphan spans, cannot join retrieve to answer becomes an outage. Customer communication templates (even if only for the drill) beat silence. If you queue deferred work, define poison-message handling. Budget documents should state the maximum extra spend allowed during retries. Close the loop by linking the containment action to a dashboard panel for trace_completeness ≥ 0.99 and p95_end_to_end_ms ≤ 2500.
Read
Field notes for `llm-tracing-lab` / `failure-handling`
Draw a state diagram for degrade modes and put it in the repo as ASCII if needed. Cap concurrent retries across the process, not only per request. Ensure cancellation propagates to downstream HTTP clients. When failing closed, choose a user-visible message that does not leak internals. Practice the single command that flips the kill switch or weight to zero. After recovery, drain or inspect deferred work before declaring green. In this chapter the product is OpenTelemetry traces across retrieve → rerank → generate for support answers, the human stakeholder is on-call engineer debugging a slow groundedness miss, and the incident id you design against is TRACE-ORPHAN-441. Re-state the oracle in your notes — fixture question produces 3 child spans; total latency attributes sum within 5% of root — and keep the invariant visible: every span carries trace_id + redacted attrs; prompts sampled ≤ 1%. Track trace_completeness ≥ 0.99 and p95_end_to_end_ms ≤ 2500 as the scoreboard. Surface under change control: POST /v1/support/answer. If you only have forty minutes, finish the fixture for missing parent context → orphan spans, cannot join retrieve to answer before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.
Go deeper
Before you start
Why this matters
Assume missing parent context → orphan spans, cannot join retrieve to answer is happening right now. Write the first safe action, the signal that confirms containment, and the action you will not take (infinite retry, broad restart, deleting evidence). Tie the plan to invariant: every span carries trace_id + redacted attrs; prompts sampled ≤ 1%.
In the wild
See how this idea shows up as a product and a company — then come back to the lesson. Skills transfer across vendors.
Related lessons
Check your understanding
Page assessment
Answer from memory. Completion is saved from this evidence, not from opening the next page.
All responses are required.