4 Topics
Chapter•60 Minutes

14. Observability and Production Operations

Trace requests, monitor ingestion freshness, manage queues, and prepare incident recovery.

Trace a RAG Request

Trace request IDs, corpus version, filters, retrieved chunk IDs and scores, reranking, prompt/model versions, citation validation, stage latency, usage, and final status. Avoid logging raw confidential text by default; restrict trace access and retention. Correlation IDs should connect API, retrieval, model, and worker events without exposing secrets.

Implementation example
{
 "traceId":"rag_abc123",
 "corpusVersion":"kb-2026-10-28",
 "retrievedChunkIds":["doc-1:4","doc-8:2"],
 "rerankerUsed":true,
 "latencyMs":1850,
 "status":"success"
}
💡 Trace metadata supports debugging while minimizing sensitive content.
Key Takeaways
  • Inspect the relevant pipeline stage instead of guessing.
  • Preserve source provenance, versions, and access scope.
  • Measure quality on representative queries.
Knowledge Check

What is a benefit of stage-level traces?

Monitor Ingestion Health and Freshness

Track source counts, last successful sync, ingestion lag, stage failures, dead letters, deletion lag, index version, and age of newest indexed content. Reconcile source counts and sample content: a successful job does not prove all documents were parsed correctly. Alert when freshness SLOs are missed.

Implementation example
Metrics:
ingestion lag | indexed documents | parse failure rate
deletion lag | dead-letter count | last successful sync
index version | stale-source rate
💡 Monitor freshness and content quality, not only worker uptime.
Key Takeaways
  • Inspect the relevant pipeline stage instead of guessing.
  • Preserve source provenance, versions, and access scope.
  • Measure quality on representative queries.
Knowledge Check

Which metric captures whether updates become searchable promptly?

Queues, Retries, and Backpressure

Use durable queues, bounded concurrency, exponential backoff with jitter, checkpoints, and idempotent upserts. Respect provider retry hints and distinguish transient errors from invalid input. Backpressure protects parsers, embedding APIs, and indexes. Quarantine poison documents instead of retrying forever. Keep ingestion capacity separate from interactive query capacity.

Implementation example
async function processJob(job) {
 try { await ingest(job); await queue.ack(job.id); }
 catch (e) {
   if (isRetryable(e)) await queue.retry(job.id, backoff(job.attempt));
   else await queue.deadLetter(job.id, safeError(e));
 }
}
💡 Production queues need visibility timeouts, retry caps, idempotency, and graceful shutdown.
Key Takeaways
  • Inspect the relevant pipeline stage instead of guessing.
  • Preserve source provenance, versions, and access scope.
  • Measure quality on representative queries.
Knowledge Check

Why bound worker concurrency?

Incident Response and Rollback

Incidents include leakage, stale policy answers, poisoned sources, provider outages, and index corruption. Prepare runbooks to disable a source or tool, switch to a prior index, limit traffic, or fall back to safe search. Preserve evidence securely, rotate exposed credentials, assess impact, and add regression cases after remediation. Audit emergency controls and practice rollback before incidents.

Implementation example
Detect -> contain source/tool/index -> protect users
 -> preserve evidence -> remediate -> validate -> restore gradually
💡 A tested runbook reduces recovery time.
Key Takeaways
  • Inspect the relevant pipeline stage instead of guessing.
  • Preserve source provenance, versions, and access scope.
  • Measure quality on representative queries.
Knowledge Check

What should follow a RAG incident fix?