Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
Python & Django

Seeing What Your AI Service Is Actually Doing

Last updated:

You cannot debug what you did not record

When someone reports a wrong answer, the questions are what was asked, what was retrieved, which prompt and model were used, and what came back. All four have to have been recorded at the time.

Reproducing an AI failure after the fact is nearly impossible without the trace. Recording it costs almost nothing and it is the difference between diagnosing and guessing.

What to record per call

  1. The input, or a reference to it
  2. The retrieved context — which passages, from which documents
  3. The prompt version and model version
  4. The raw output, before any post-processing
  5. Latency, tokens and cost
  6. Any validation failure or retry

Metrics that matter

MetricWatch for
Latency percentilesDegradation, not just averages
Error and retry rateProvider or prompt problems
Validation failure rateOutput drifting from the schema
Refusal rateRetrieval broken
Cost per requestContext growing
Correction rateQuality degrading

Correlate with the originating request

A single user action may trigger retrieval, several model calls and a queued job. Without a shared identifier across all of them, tracing what happened means guessing.

Generate it once at the boundary and carry it everywhere, including into queued work.

Mind what you log

  • Retrieved passages may contain personal or sensitive data
  • Log references rather than content where the material is sensitive
  • Apply a retention period automatically
  • Remember these logs are in scope for data requests
  • Restrict who can read them

Frequently asked questions

Do we need a dedicated observability tool?

Useful at scale. Structured logging with a correlation identifier covers most needs for a single service.

How long should traces be kept?

Thirty to ninety days for diagnosis. Longer where they serve as an audit record, subject to your data obligations.

What about the storage cost?

Modest for text. Storing references rather than full content keeps it small even at volume.

Should we sample rather than record everything?

Record everything at business volumes. Sampling means the failure you need to diagnose is the one you did not record.

Keep reading

Cannot explain why your AI gave that answer?

That is a tracing gap rather than a model problem. Happy to add proper observability to an existing service.

Book a free 30-minute call Get a project estimate WhatsApp us

Related services

What we build for problems like this one

Custom Software DevelopmentWeb DevelopmentMachine Learning