Skip to content
PHP2Shell: The PHP Bug
Akshay Thakare

Observability for LLM Applications

What to log for every LLM and agent call — prompts, tokens, latency, tool calls, outcomes — and how to turn traces into fixes.

AI ToolsIntermediate2 min readUpdated 11 Oct 2026

Why normal logs are not enough

An LLM app can return HTTP 200 with a wrong, slow or expensive answer. You need to see what the model saw, what it did and what it cost.

What to record per request

FieldWhy
Trace id, user / session, featureGroup steps and find a user's problem
Model and parametersReproduce behaviour
Prompt (or template + variables) and responseDebug wrong answers
Retrieved document idsTell retrieval failures from generation failures
Tool calls: name, arguments, result, durationDebug agents
Input / output tokens, latency, costBudget and performance
Outcome: user feedback, eval score, errorMeasure quality

Traces for agents

An agent run is a tree: plan → tool call → model call → tool call. A trace view shows where time and tokens went and which step went wrong.

Turn traces into improvements

  1. Sample failed or low-rated traces each week.
  2. Label the failure type: retrieval miss, wrong tool, bad instruction, hallucination.
  3. Add the case to the evaluation set.
  4. Fix, re-run evals, and ship only if nothing else regresses.

Finished this note?

Share