Observability for AI Systems
Token metrics, tracing across model calls, cost attribution, and the hard part — monitoring output quality when there is no ground truth and no exception to catch.
#The gap ordinary monitoring leaves
Standard observability answers: is it up, is it fast, is it erroring. All three can be perfectly green while an AI system is failing badly.
TRADITIONAL SIGNALS WHAT THEY MISS
error rate 0.01% ✓ the model is confidently wrong
p99 latency 800ms ✓ answers got shorter and less useful
CPU 40% ✓ GPU KV cache is at 98%
200 OK ✓ every response says "I cannot help"
→ An AI system degrades along a dimension that
conventional monitoring has no view of at all.You need three layers:
- the serving layer — the same kinds of latency and throughput metrics you already know, but counted in tokens rather than requests;
- the request layer — tracing one user action across the many model calls it triggers;
- the quality layer — whether the answers are actually any good, the genuinely hard one.
#Layer 1 — serving metrics
The unit is tokens, not requests. Everything else follows from that.
| Metric | Definition | Why it's the right one |
|---|---|---|
| TTFT | Queue wait + prefill | What users perceive as responsiveness |
| TPOT | Time per output token | Streaming smoothness; under ~30 ms feels fluid |
| End-to-end latency | TTFT + TPOT × output length | Dominated by output length, so it's mostly not about your system |
| Throughput | Tokens/second, in and out separately | Your cost denominator |
| Goodput | Tokens/second meeting SLA | The honest number |
| KV cache utilisation | Fraction of cache allocated | The real capacity signal — watch this, not GPU% |
| Batch size | Concurrent sequences per step | Directly proportional to efficiency |
| Preemption rate | Evictions per minute | Non-zero means admission control is too loose |
| Queue wait | Time from arrival to first forward pass | The controllable part of TTFT |
GPU utilisation is nearly useless. nvidia-smi reports ~100% whenever any kernel is resident, including one stalled on memory. Use KV cache utilisation for capacity and MFU for efficiency instead.
#Layer 2 — tracing
One user action can be twenty model calls, several retrievals, and a handful of tool executions. A trace records that whole tree — every step, nested, with its own timing — so you can see where the 40 seconds actually went. Each individual step in it is a span. Without one, you have a total and no way to attribute it.
TRACE: "summarise this repo and fix the failing test" 47.2 s
├─ classify intent 0.3 s (small model)
├─ retrieve repo context 1.1 s
│ ├─ embed query 0.08 s
│ └─ vector search (top 40) 0.9 s
├─ agent loop 44.8 s ← here
│ ├─ turn 1 model call 2.1 s 4.2K in / 180 out
│ │ └─ tool: read_file 0.2 s
│ ├─ turn 2 model call 3.4 s 6.8K in / 310 out
│ │ └─ tool: run_tests 18.3 s ← and here
│ ├─ turn 3 model call 4.9 s 11K in / 520 out
│ └─ ... 6 more turns
└─ format response 1.0 s
Two findings visible immediately:
· run_tests dominates — not a model problem at all
· input tokens grow every turn (4.2K → 11K), so
later turns cost multiples of earlier onesEvery span should carry: model and version, input tokens split into cached and uncached, output tokens, computed cost, temperature and sampling params, the prompt template version, and whether it was a retry.
Sampling strategy matters. Full traces are expensive at volume. Sample 1–5% uniformly for baselines, plus 100% of anything anomalous — errors, latency outliers, high cost, low confidence, negative user feedback. The anomalous traces are the ones you'll actually read.
Prompt versioning is part of tracing. When quality shifts, "which prompt version was this?" is the first question, and it's unanswerable unless you record it. Prompts should be versioned artifacts, not string literals in the codebase.
#Layer 3 — quality
The hard part. There is no exception when a model gives a bad answer, and usually no ground truth — a known correct answer to compare it against. So you watch indirect signals instead.
Proxy signals — cheap, fast, high volume:
| Signal | What it catches |
|---|---|
| Output length distribution | Truncation, runaway generation, format collapse |
| Refusal rate | Alignment drift in either direction |
| Tool-call validity | Structured-output degradation — the most sensitive signal available |
| Retry / regeneration rate | Users silently saying the answer was bad |
| Conversation length | Rising turns-to-resolution means answers aren't landing |
| Fallback / escalation rate | The explicit failure path |
| Empty or near-empty responses | Prompt or template breakage |
Direct signals — slower, more meaningful:
- Explicit feedback (thumbs). Sparse — typically 1–5% of users respond — and biased toward extremes, but unambiguous when you get it.
- Implicit feedback. Did they copy the code? Accept the suggestion? Continue the conversation? Often far more informative than thumbs, and available on every interaction.
- Task success. Did the ticket get resolved, the test pass, the purchase complete? This is the real metric and it lags by hours or days.
- LLM-as-judge on a live sample. Score a percentage of production traffic with a model. Fast and scalable, but it needs its own validation against human labels. The judge's score is already only an estimate of quality; if you never check the judge against humans, you can't tell whether a change in its score reflects your model or the judge's own blind spots. Covered in evaluation systems.
#Cost attribution
Covered in the cost model; the observability requirement is that every span carries enough to compute cost, and that you can aggregate by tenant, feature, model, and endpoint.
What you're looking for, specifically:
· top 1% of users by cost — usually 30-50% of the bill
· cost per feature vs its value
· cached vs uncached input ratio, per endpoint
→ a falling ratio means prompt ordering broke
· agent loops exceeding expected turn counts
· retry storms — invisible in request counts, obvious in tokensThat third one is worth alerting on. Prefix caching only reuses work when the start of a prompt is identical to one seen before, so the stable parts (system prompt, tool definitions) must come first. If someone puts a timestamp at the front of a prompt, every request now starts differently, nothing matches the cache, and the hit rate silently collapses. That can double your bill with no other symptom.
#Alerting
Not everything above deserves a page. A workable split:
Page immediately: TTFT p99 above SLA for 5 minutes; error rate above baseline; KV cache above 95% with preemptions occurring; cost rate above 2× the 7-day average; tool-call validity dropping more than 5 points.
Ticket, don't page: gradual quality drift; cost per request trending up; cache hit rate declining; MFU below target.
Dashboard only: length distributions, per-feature breakdowns, model mix.
#Exercise
#Check yourself
Why isn't traditional monitoring enough for AI systems?Show answer
Which serving metrics matter?Show answer
Why is end-to-end p99 latency misleading?Show answer
What should every trace span carry?Show answer
Name five quality proxies that need no ground truth.Show answer
What direct quality signals exist?Show answer
Why alert on the cached-input ratio?Show answer
How should AI alerts be written?Show answer
#What to carry forward
- Traditional monitoring can be entirely green while quality collapses.
- Alert on TTFT and TPOT separately. End-to-end p99 mostly measures output length.
- KV cache utilisation is the capacity signal; GPU utilisation is close to meaningless.
- Trace every model call with tokens, cost, model version, and prompt version.
- Five quality proxies cost nothing and need no ground truth: length, validity, refusal, retry, cost.
- Build the quality baseline before the incident. Without history, no number is interpretable.
- Alert on rates and distribution shifts, never absolute counts.