LLM Observability: Tracing, Logging and Monitoring AI Applications
How to observe LLM apps in production: traces of prompts and tool calls, token and cost metrics, latency, quality signals, OpenTelemetry GenAI conventions.
Published December 1, 2026
When an AI feature gives a bad answer in production, you need to see exactly what happened: which prompt was sent, what was retrieved, which tools were called with what arguments, how long each step took and what it cost. LLM observability applies tracing and monitoring practices to these new kinds of operations so you can debug, improve quality and control spend.
The concept
A trace represents one user request end to end, made of spans for each step: retrieval, each model call, each tool call, post-processing. For model calls you capture the model name, parameters, input and output (subject to privacy policies), token counts, latency and errors. For agents, traces show the full tree of decisions, which is essential for understanding loops and failures.
Metrics aggregate across traces: requests per feature, p50/p95 latency, time to first token, tokens and cost per request, error and fallback rates, cache hit rates, and quality signals such as thumbs-up rates, eval scores on sampled traffic and guardrail triggers. OpenTelemetry has semantic conventions for generative AI so these spans can flow into standard observability backends as well as specialised LLM tools.
Anatomy of an LLM trace
What to monitor
| Signal | Why | Example alert |
|---|---|---|
| Latency (p95, TTFT) | User experience | p95 > 8 s for 10 min |
| Tokens and cost per feature | Budget control | Daily spend > 150% of baseline |
| Errors, rate limits, fallbacks | Reliability | Fallback rate > 5% |
| Quality (feedback, sampled evals) | Detect regressions | Thumbs-down rate doubles |
| Guardrail triggers | Safety and abuse | Spike in blocked injections |
Instrumentation pipeline
Practical examples
Manual OpenTelemetry span for a model call
Attribute names follow the GenAI conventions (check current spec).
from opentelemetry import trace
tracer = trace.get_tracer("support-bot")
with tracer.start_as_current_span("chat " + MODEL) as span:
span.set_attribute("gen_ai.request.model", MODEL)
resp = client.chat.completions.create(model=MODEL, messages=msgs)
span.set_attribute("gen_ai.usage.input_tokens", resp.usage.prompt_tokens)
span.set_attribute("gen_ai.usage.output_tokens", resp.usage.completion_tokens)Structured log line per call
Even without tracing, consistent logs enable cost and latency reporting.
{"ts":"2026-11-30T10:12:03Z","feature":"ticket-summary","model":"fast","in_tokens":2210,
"out_tokens":180,"latency_ms":1430,"cost_usd":0.0021,"fallback":false,"trace_id":"7f3a..."}Capture user feedback against the trace
Link thumbs up/down to the exact trace for debugging.
POST /api/feedback {"trace_id": "7f3a...", "rating": "down", "comment": "wrong refund amount"}Common mistakes
- Logging full prompts with personal data and no retention policy.
- Tracking cost only at the monthly invoice level.
- No link between user feedback and the trace that produced the answer.
- Sampling so aggressively that rare failures are never captured.
Key takeaways
- Trace every step: retrieval, model calls, tool calls.
- Monitor latency, tokens, cost, errors and quality together.
- Use OpenTelemetry GenAI conventions where possible.
- Redact sensitive data and link feedback to traces.
FAQ
Do I need a specialised LLM observability product?
Not to start. Structured logs and OpenTelemetry into your existing stack go far; specialised tools add prompt diffing, eval integration and nicer agent views.
Should I log full prompts?
Log enough to debug, with redaction, access controls and retention limits that match your privacy obligations.
How do I track cost per customer?
Attach customer and feature IDs to every span or log line and aggregate token costs by them.