Zenaique

Select the signals a production RAG system must log to make failures debuggable

Multi-select·Medium·4.0 · 0·~1 min·Asked atIntuitPineconeSourcegraph
Attempt it
TL;DR

Log the query and its rewrite, retrieved chunk IDs with scores, the prompt and answer, and per-stage latency, cost, and feedback — enough to replay a request and localize the fault.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a relay race where the baton gets dropped but you only filmed the finish line. You see the team lost, but you have no idea which runner fumbled. To actually fix it, you need a camera at each handoff. RAG logging works the same way. The answer is the finish line. To debug a bad answer, you need a record at each handoff: what the question became, which documents were grabbed and how well they scored, what got handed to the model, and how long and how much each leg cost. With those, you can rewind the race and point to the exact runner who dropped the baton.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

A RAG answer is the end of an assembly line: rewrite the query, embed it, retrieve candidates, rerank them, build a prompt, generate. When the answer is wrong, the failure already happened somewhere up that line. The entire job of observability is to let you walk back along it and find the station that broke.

That reframes the multi-select. The question is not really 'what data exists?' — it is 'what data lets you replay a request and localize its failure to one stage?' Some fields are diagnostic gold; some are the symptom dressed up as a log; and some are bulk data that belongs in the index, not the request trace.

This deep dive works through why the four winning signals each isolate a different stage, why the two distractors fail on different grounds, and how production teams in 2026 wire this up with tracing so the same data both debugs incidents and feeds offline evaluation. The throughline: log for the question you will be forced to answer under pressure — which stage do I fix?

Failure localization is the design goal

RAG has at least three stages that can each independently ruin an answer. Retrieval can fail to surface the chunk that holds the answer. Ranking can surface it but bury it below the top-k cutoff so it never reaches the prompt. Generation can receive the right chunk and still hallucinate, get lost in the middle of a long context, or follow an injected instruction. Three stages, three distinct fixes — different team, different code path, different test.

If your telemetry cannot tell these apart, every incident degrades into guessing. You see a wrong answer, you have a hunch, you tweak the chunk size, and you hope. That is not debugging; it is superstition.

So the design rule is simple: log enough per request to replay it and attribute the failure. Replay means you could reconstruct what each stage saw and produced. Attribute means the logged fields directly answer 'was the right chunk retrieved?', 'did it survive ranking?', and 'did the model use it?'. Every field worth keeping earns its place by advancing one of those three questions. Every field that does not is either noise or cost.

Walking the four winning signals
Why the two distractors are wrong on different grounds
Wiring it up: tracing in the 2026 stack
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
SignalLog it?What it lets you diagnose
Query + rewritten formYesQuery transformation mangling recall
Chunk IDs + scoresYesRetrieval miss vs ranking miss
Assembled prompt + answerYesContext present but model ignored it
Per-stage latency/cost/feedbackYesPerformance and quality, with labels
Final answer onlyNoSymptom only — cannot localize cause
Raw vector of every chunk/requestNoNothing a chunk ID does not already give

Real products, models, and research that use this idea.

  • LangSmith traces each RAG step as a nested run, capturing the rewritten query, retrieved documents with scores, the final prompt, the answer, and per-step latency and token cost.
  • Langfuse models a request as a trace of spans (retriever, reranker, generation) and attaches user feedback scores, then feeds those traces into dataset-based evaluation.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow do you use logged scores to separate a retrieval miss from a ranking miss?
A

Build a small labeled set where you know which chunk holds the answer. For each query check whether that chunk id appears anywhere in the retrieved set: absent means a retrieval miss (fix embeddings, chunking, or index recall); present but below the top-k cutoff means a ranking miss (fix the reranker or widen the funnel). The score column tells you which without re-running the query.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Logging only the final answer to save space. When the answer is wrong you cannot tell whether retrieval missed the chunk, ranking buried it, or the model ignored it — the one record you kept is the one that explains the least.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • State the goal of RAG observability in one phrase: replay and localize the failing stage.

  • List the four signal groups worth logging on every request.

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Which metric best measures whether a RAG answer is grounded in the retrieved context?
MCQ·Medium