This comprehensive guide explains how to build an observability practice for production LLM applications. It covers what to measure, how to instrument your pipeline, which metrics matter most, and how to act on the signals you collect. It draws on publicly documented practices from leading AI providers and open-source observability tooling.
Why LLM Observability Is Different
Traditional observability rests on three pillars: metrics, logs, and traces. LLM applications need all three, but they also require LLM-specific signals that standard APM tools do not capture.
Probabilistic Outputs
A deterministic API returns the same response for the same input. An LLM does not. Two identical prompts can yield different completions depending on sampling temperature, model version drift, or system prompt changes. Observability must therefore capture not just that a request succeeded, but what the model actually produced, and whether that output meets quality thresholds.
Token-Level Cost
Most LLM providers bill per input and output token. A sudden spike in output length — for example, a prompt template change that causes the model to emit verbose explanations — can multiply costs without any change in request volume. Observability must track token consumption per request, per user, and per model version.
Context Window Behavior
LLMs have finite context windows. As conversations grow, the system may truncate, summarize, or compress earlier messages. Without observability, you cannot tell whether a poor answer resulted from missing context or from model weakness.
Prompt and Chain Complexity
Modern LLM applications are rarely a single model call. They involve retrieval-augmented generation, tool use, multi-step agents, and chained prompts. A failure at step two can poison step three. Observability must trace the full chain, not just the final response.
What to Measure
Request-Level Metrics
- Request volume: total inference calls per minute, hour, and day, broken down by model and endpoint.
- Latency: time to first token (TTFT), time per output token, and end-to-end response time. TTFT matters most for interactive chat; total time matters for batch jobs.
- Error rate: HTTP errors, malformed model outputs, rate-limit hits, and provider outages.
- Token usage: input tokens, output tokens, and total tokens per request. Track by model to compare costs.
Quality Metrics
- Grounding/faithfulness: whether the model's answer is supported by retrieved context. This is essential for RAG systems.
- Answer relevance: whether the response actually addresses the user's question.
- Context relevance: whether the retrieved documents contain the information needed to answer.
- Hallucination rate: the share of outputs containing unsupported claims. This requires either human review or an LLM-as-a-judge setup.
Cost Metrics
- Cost per request: input token cost plus output token cost, using the provider's published pricing.
- Cost per user or per feature: attribute token spend to specific customers or product areas.
- Cost trend: week-over-week changes that may signal prompt bloat, model switching, or traffic growth.
Instrumenting the Pipeline
Trace Every Chain Step
Instrument each stage of your LLM pipeline as a separate span in a trace:
- User input received
- Prompt template rendering
- Retrieval (vector search, keyword search, or both)
- Context assembly
- Model inference
- Output parsing and validation
- Final response to user
Each span should record the input, output, latency, token count, and any errors. If step three returns irrelevant documents, the trace makes that visible instead of blaming the model.
Capture Prompt and Model Versions
Record the exact prompt template version, system prompt, model ID, and inference parameters (temperature, top-p, max tokens) for every request. Model providers periodically release new versions with different behavior; versioned observability lets you correlate quality changes with deployments.
Log Inputs and Outputs Carefully
LLM inputs and outputs may contain sensitive data. Before logging, apply redaction rules to strip PII, credentials, and proprietary information. Store raw prompts and completions in a segregated, access-controlled store, and keep retention periods short for high-sensitivity fields.
Metrics That Matter Most
Start with a small, actionable set rather than boiling the ocean:
| Metric | Why It Matters | Alert Threshold Example |
|---|---|---|
| Error rate | User-facing failures | > 1% over 5 minutes |
| P95 latency | Interactive experience | > 5 seconds for chat |
| Output tokens per request | Cost driver | 2x baseline average |
| Faithfulness score | RAG accuracy | < 85% of sampled requests |
| Cost per day | Budget control | > 20% week-over-week increase |
Alert on trends, not just absolute values. A gradual increase in output token length may be harmless — or it may indicate a prompt change that accidentally made the model verbose.
Working with LLM-as-a-Judge
Because human review cannot scale to every model response, many teams use a capable "judge" model to score a sample of production outputs. The judge receives the user query, the retrieved context, and the candidate answer, then rates faithfulness, relevance, and safety on a defined scale.
Important caveats:
- The judge model is itself probabilistic. Use it for trends and sampling, not as a source of absolute truth.
- Calibrate the judge against human-labeled examples before trusting its scores.
- Do not use the same model to generate and judge outputs without independent validation; correlated biases can hide real problems.
Cost Control in Practice
Token billing makes cost observability non-optional. Practical steps include:
- Prompt caching: Many providers cache repeated prefixes. Structure prompts so stable instructions come before variable user input.
- Response caching: Cache answers to frequent, deterministic queries (for example, "What are your business hours?").
- Model routing: Send simple queries to smaller, cheaper models and reserve large models for complex reasoning.
- Max output tokens: Set hard caps to prevent runaway generation from inflating costs.
Common Pitfalls
- Measuring only success rate: A 200 OK response can still contain a useless or harmful answer. Pair infrastructure metrics with quality sampling.
- Ignoring context truncation: If your system silently drops early conversation turns, quality will degrade without an obvious error signal.
- No version tracking: Without prompt and model version metadata, you cannot tell whether a quality dip is caused by a deployment or by external factors.
- Logging everything unfiltered: Raw prompts may contain secrets. Redact before you store.
Getting Started
If you have no observability in place today, start small:
- Add a trace ID to every LLM request and log input/output token counts.
- Instrument the model call itself: latency, model ID, temperature, max tokens.
- Sample 5–10% of responses for human or LLM-judge quality review.
- Build a dashboard showing daily request volume, error rate, P95 latency, and estimated cost.
- Add one alert: error rate above threshold.
From there, expand to full chain tracing, per-user cost attribution, and automated quality scoring. Observability is an investment that pays off every time you catch a regression before your users do.
Conclusion
LLM observability is not optional infrastructure — it is the lens through which you operate a production AI system. Traditional metrics tell you whether the service is up; LLM-specific observability tells you whether it is useful, accurate, and affordable. By tracing every chain step, versioning prompts and models, measuring quality as well as throughput, and controlling token costs, teams can run LLM applications with the same confidence they expect from traditional software.
Sources
Related Catalog Entry: AI Model Evaluation Best Practices 2026 - Complementary guidance on evaluating AI model quality in production environments.