Slides · Production: cost, serving and observability

Observability and eval pipelines

Observability and eval pipelines

What to record on every LLM request, what to watch live, and how to stop a regression before users meet it.

Concept

An hour of wrong answers, and nobody noticed

  • At 2 am the delivery cut-off answers were wrong for an hour. Customers noticed first, in their reviews.
  • Ordinary software can be unit-tested with ==. An LLM system cannot: output varies, “correct” is often a judgement, and prompt, model, retrieval and tools each change on their own schedule.
  • So production needs two things that work together: tracing and monitoring (online) and an evaluation pipeline (offline).

By the end you can:

  1. List what to record per request and why.
  2. Say what online monitoring catches and what only an offline golden set catches.
  3. Run the loop from traces to labelled cases to a gate, reading results per slice.
  4. Choose alerts and a privacy policy for logged prompts.

Diagram

Flight recorder and test rig

Diagram: Every request is traced.

yes

no

Incoming request

Trace logged

Live monitoring dashboard

Trace store

Offline eval: golden set on every change

Regression?

Block the change

Ship

Diagram summary: Every request is traced. Traces feed a live dashboard and a store. The store supplies cases for offline evaluation, which blocks a change that regresses the golden set and ships the rest.
  • The flight recorder (traces) tells you something went wrong after users met it. The test rig (golden set) tells you before.
  • Anthropic’s engineering post on agent evals describes layers: automated evals before launch and in CI/CD, then production monitoring for drift and failures nobody anticipated. No single layer catches everything.

Source1 Demystifying evals for AI agents

Diagram

A trace is timed steps under one id

Diagram: One trace id sits at the top with four sibling spans below it, one per stage of a RAG request, listed in the order they ran, each with its...

Trace 4f2a: one RAG request, 2.9 s

rewrite
0.3 s

retrieve
0.2 s

rerank, build prompt
0.5 s

generate
1.9 s

chunk ids and scores

prompt version, model, tokens, cost

Diagram summary: One trace id sits at the top with four sibling spans below it, one per stage of a RAG request, listed in the order they ran, each with its own timing. Dotted lines show attributes that explain a step, such as the chunk ids retrieved or the model and cost of generation. The timings are invented for illustration.
  • The OpenTelemetry GenAI conventions define spans for operations such as inference, embeddings and retrieval.
  • Each step is a span, so you can see which stage is slow or wrong.

Source2 OpenTelemetry GenAI Semantic Conventions

Compare

What to record, and the question each field answers

FieldQuestion it answersOpenTelemetry (GenAI conventions)
Trace id, timestamp, tenant or hashed user idWhich requests belong together? Which user to delete?Trace id is built into OpenTelemetry span context; no GenAI attribute for tenant
Versions: prompt, embedding model, chunker, index, rerankerWhat changed when quality moved?No GenAI attribute; use your own. gen_ai.request.model and gen_ai.response.model cover the model
Rewritten query, retrieved chunk ids and scoresRetrieval failure or generation failure?gen_ai.retrieval.documents (Opt-In) and gen_ai.retrieval.query.text (Opt-In)
Final prompt tokens; prompt text (by policy)Can I reproduce the input and explain cost?gen_ai.usage.input_tokens; gen_ai.input.messages (Opt-In)
Raw response, stop reason, tool callsWhy did it say that? Was it truncated?gen_ai.output.messages (Opt-In), gen_ai.response.finish_reasons
Input, output, cached tokens; latency per stage; costWhere do money and seconds go?gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, gen_ai.usage.cache_read.input_tokens; cost is yours
ErrorsReliability analysiserror.type (Stable)
Guardrail outcome, retries, fallbacksSafety and reliabilityNo GenAI attribute; use your own
Outcome signals: thumbs, regeneration, copy, escalationWeak live evidence of qualityNo GenAI attribute; use your own
  • Attribute names above come from the OpenTelemetry GenAI repository’s spans and inference documents (checked 2026-10-23). Apart from error.type, they carry Development status, so names can still change.

Source2 OpenTelemetry GenAI Semantic Conventions

Worked example

Worked example: which stage is slow?

Users report that some answers take close to 10 seconds. Normal requests take about 2.9 s. Three slow traces (illustrative):

TraceStage times (s)TokensVerdictFirst thing to check
Arewrite 0.3, retrieve 4.8, rerank 0.4, generate 1.9; total 7.4normalRetrieval is slowVector store load, index version
Brewrite 0.3, retrieve 0.2, rerank 0.4, generate 9.0 (TTFT 0.6); total 9.9840 output at 100 tokens/sAnswer too longPrompt version, output limit
Crewrite 0.3, retrieve 0.2, rerank 0.4, generate 6.5 (TTFT 5.8); total 7.414,000 input, 0 cachedPrompt grew and missed the cacheChunks per prompt, prefix layout
  • The totals look alike; the per-stage spans plus token and cached-token fields separate three different causes.
  • Check B: decode time 9.0−0.6=8.4 s9.0 - 0.6 = 8.4\ \text{s}, and 8.4×100=8408.4 \times 100 = 840 tokens.

Concept

Standard names exist, but check their status

  • The GenAI conventions moved: the old opentelemetry.io spec page now says they live in a separate repository (page viewed 2026-10-23).
  • The repository’s spans document is marked Development status, and its attribute tables mark individual attributes as Development too.
  • Content-carrying attributes (retrieved documents, query text, output messages, system instructions, tool definitions) are marked Opt-In, and some carry a note that they may contain sensitive information, including personal data.
  • Takeaway: adopt the names where they fit, keep your own field list as the contract, and treat content capture as a policy decision.

Source2 OpenTelemetry GenAI Semantic Conventions

Compare

Online signals: fast, real, noisy

GroupExample signalsWhat it cannot tell you
ReliabilityError rate, timeouts, retry and fallback rateWhether answers are right
Latencyp50, p95, p99 per stage; TTFTWhy a stage is slow
CostCost per request and per tenant; input token countWhether the spend bought quality
BehaviourAbstention rate, empty-retrieval rate, guardrail and refusal rateWhich change caused a jump
Quality proxiesThumbs-down and regeneration rate; a sampled groundedness or judge scoreAnything for the many users who never click
DriftShifts in query topics, retrieval score distribution, document freshnessWhat to fix
  • Alert on change relative to your own baseline, not on numbers copied from a blog.
  • A sudden jump in abstention or refusal rate in either direction means something changed.
  • Few users give feedback and those who do are not representative.

Worked example

Worked example: a baseline-relative threshold

Signal: the empty-retrieval rate. Baseline 3 percent over 2,000 requests per hour (illustrative).

standard error=p(1−p)n=0.03×0.972000=0.0038\text{standard error} = \sqrt{\frac{p(1 - p)}{n}} = \sqrt{\frac{0.03 \times 0.97}{2000}} = 0.0038alert threshold=p+3×standard error=0.03+0.0114=0.0414\text{alert threshold} = p + 3 \times \text{standard error} = 0.03 + 0.0114 = 0.0414
HourRequestsEmpty retrievalsRateAlert?
12,000643.2%No
22,000964.8%Yes, above 4.14%
  • “3 standard errors” is a starting choice, not a law. Tune it on your history, and allow for daily and weekly patterns in the baseline.
  • The alert says behaviour changed. The trace fields (versions, retrieved ids) tell you why.

Compare

What each one catches

AspectOnline monitoringOffline golden-set eval
WhenAfter users are affectedBefore the change ships
DataReal traffic, unlabelledCurated cases with expectations
StrengthCatches drift, outages, cost leaks, data changes with no releaseCatches regressions in rare intents and slices; compares versions fairly
WeaknessNoisy; slow to move for a small slice; shows that something changed, not whatOnly covers cases you thought to include; needs upkeep
Failure mode on its ownAggregate rates can stay flat while a slice breaksA passing set says nothing about tomorrow’s data

Anthropic’s agent-evals post recommends combining three layers: automated evals “for fast iteration”, production monitoring “for ground truth”, and periodic human review for calibration (quotation marks mark its wording).

Source1 Demystifying evals for AI agents

Check yourself

Check: which layer catches it?

For each incident, say whether live monitoring or the pre-release golden-set gate is the better first catch.

  1. One tenant’s cost per request triples because a client library retries in a loop.
  2. The team upgrades the judge model used for sampled quality scores, and the scores jump with no change to the answers.
  3. The provider starts timing out at 6 pm.
  4. A nightly re-embedding job fails halfway, leaving the index part old and part new.
Answer
  1. Live: cost per tenant and retry rate show it within minutes. 2. Offline: re-run the judge on a human-labelled set and compare agreement before trusting the new scores. 3. Live: error and latency alerts. 4. Live: no release is involved, so retrieval-score distribution, empty-retrieval rate and sampled groundedness are the early warning. A scheduled eval run after the job also helps.

Concept

What goes in a golden set

  • Inputs with expectations about the output, grouped into kinds of case: should retrieve and answer, should say “I don’t know”, should ask a clarifying question, adversarial or injection attempts, and every past incident.
  • Tag each case with a slice: topic, tenant type, language, difficulty.
  • Start small. Anthropic’s post calls 20 to 50 tasks built from real failures “a great start” (quoted). Husain describes tests scoped by feature and scenario that are cheap enough to run on every change.
  • Run it on every change to the prompt, model, retriever, chunker or embedding model, and compare with the current baseline.
  • Score retrieval (did the right chunk id appear in the top k?) separately from generation (was the answer faithful and complete?). That is why the trace stores retrieved ids.

Sources3 Your AI Product Needs Evals1 Demystifying evals for AI agents

Diagram

The gate, step by step

Diagram: A change runs against the golden set and the results are compared with the baseline slice by slice.

yes

no

Proposed change

Run the golden set

Compare with baseline, per slice

Any slice worse than noise allows?

Read the failing cases

Fix, or block the change

Ship in stages

Diagram summary: A change runs against the golden set and the results are compared with the baseline slice by slice. If any slice is worse than noise allows, the failing cases are read and the change is fixed or blocked. Otherwise it ships in stages.

Math

How noisy is a pass rate?

standard error=p(1−p)n\text{standard error} = \sqrt{\frac{p(1 - p)}{n}}
SymbolMeaning
ppObserved pass rate (share of cases passed)
nnNumber of cases in the set or slice

For the gap between two independent runs: p1(1−p1)n1+p2(1−p2)n2\sqrt{\dfrac{p_1 (1 - p_1)}{n_1} + \dfrac{p_2 (1 - p_2)}{n_2}}.

Cases nPass rate pStandard errorIn points
250.90.9×0.125=0.06\sqrt{\dfrac{0.9 \times 0.1}{25}} = 0.066
1000.90.9×0.1100=0.03\sqrt{\dfrac{0.9 \times 0.1}{100}} = 0.033
4000.90.9×0.1400=0.015\sqrt{\dfrac{0.9 \times 0.1}{400}} = 0.0151.5
  • A rough guide that treats the cases as a random sample of future traffic. The difference between two runs is noisier than either run.
  • A one-point gain on 100 cases is inside the noise. A small slice is noisy but can still show a large fall.

Worked example

Worked example: the average hides a collapse

Illustrative golden set of 150 cases, gated on quality and on p95 latency (limit 5 s, illustrative). Prompt v8 is the baseline; v9 adds more retrieved context.

SliceCasesv8 passesv9 passesv8 p95v9 p95
General10085 (85%)96 (96%)2.1 s2.2 s
Long-document questions2520 (80%)21 (84%)3.4 s9.8 s
Tool-call questions2520 (80%)20 (80%)2.8 s2.9 s
Total150125 (83.3%)137 (91.3%)
  • Headline quality: up 8.0 points. The standard error of the difference between two runs is 0.833×0.167150+0.913×0.087150=0.038\sqrt{\dfrac{0.833 \times 0.167}{150} + \dfrac{0.913 \times 0.087}{150}} = 0.038, so the gain is about 2.1 standard errors: probably real. This treats the runs as independent; the same cases are scored twice, so it is a conservative guide.
  • Long-document slice: p95 latency rises from 3.4 s to 9.8 s, over the 5 s limit, and its quality gain is only one case.
  • Gate on more than one metric per slice. A better average quality score can hide a latency (or cost) regression in one slice.

Process

Closing the loop

  1. Sample production traces, weighted toward thumbs-down, abstentions, low-confidence retrievals, escalations and new topics.
  2. Label them, by people or by a calibrated judge checked by people. Fix the prompt, retrieval or data.
  3. Add the labelled cases to the golden set with slice tags, after redaction.
  4. Gate the next change on the enlarged set for quality, latency and cost, then roll out in stages.

Why calibrate a model judge: the MT-Bench paper reports that strong judges agree with human preferences more than 80 percent of the time in its setting, and also documents position, verbosity and self-enhancement biases. Husain’s advice is to align the judge with a human and track their agreement.

Sources3 Your AI Product Needs Evals4 Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena

Diagram

The loop as a picture

Diagram: Production traces are sampled and labelled.

Production traces

Sample the interesting ones

Label them

Fix prompt, retrieval or data

Add to the golden set with slice tags

Gate the next change

Diagram summary: Production traces are sampled and labelled. The failures are fixed and also added to the golden set with slice tags. The next change is gated on the enlarged set and then produces new traces, so the set grows from real incidents.
  • Husain describes a cycle in which evaluating, debugging and changing the system speed one another up, and failures seen in real use become new tests.

Source3 Your AI Product Needs Evals

Check yourself

Check: is the judge any good?

A team calibrates a model judge on 100 human-labelled traces. Humans marked 90 as good and 10 as bad. The judge said “good” for all 100. It reports 90 percent agreement with humans. What is wrong, and what should they measure instead?

Answer

The classes are imbalanced, so a judge that never flags anything still agrees on 90 of 100. Its recall on the bad answers is 0 of 10. Husain advises looking at precision and recall separately rather than raw agreement. The team should measure how many of the 10 bad answers the judge catches and how often it flags good ones, and improve the judge prompt until it does.

Source3 Your AI Product Needs Evals

Concept

Traces are sensitive data

A trace holds user text, retrieved company documents and model output. Treat the trace store as production data.

  • Redact personal data and secrets before storing, or keep identifiers and hashes instead of text.
  • Restrict: most engineers get redacted views. OWASP lists least-privilege access among its mitigations for sensitive information disclosure.
  • Expire: set a retention period and delete on schedule. OWASP also advises that you “maintain clear policies about data retention, usage, and deletion”.
  • Honour deletion across traces, caches and exported datasets. Check your own legal requirements.
  • Sample full-content capture if you do not need every request. OpenTelemetry marks content attributes as opt-in.
  • Same rules for the golden set: do not copy raw production traces into it.

Sources5 LLM02:2025 Sensitive Information Disclosure2 OpenTelemetry GenAI Semantic Conventions

Code

Redaction and a pseudonymous id

Python

import re, hmac, hashlib

EMAIL = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")
PHONE = re.compile(r"(?<!\d)(?:\+?\d{1,3}[ -]?)?\d{10}(?!\d)")
KEY = re.compile(r"\b(?:sk|pk)-[A-Za-z0-9_-]{16,}")

def redact(text: str) -> str:
    text = EMAIL.sub("[EMAIL]", text)
    text = KEY.sub("[SECRET]", text)
    return PHONE.sub("[PHONE]", text)

def pseudonym(user_id: str, secret: bytes) -> str:
    return hmac.new(secret, user_id.encode(), hashlib.sha256).hexdigest()[:16]

Results of running it (Python 3):

TestInputResult
Emailananya.rao@example.com[EMAIL]
Phone9876543210, and +91 9876543210[PHONE]
Key-like stringssk-abcdef0123456789ABCD, sk-abcdef0123456789ABCD_extra, sk-ant-api03-..., sk-proj-...[SECRET] for each, whole string
Other key formatghp_AbCdEf0123456789... (40 characters)Not caught as a key, and any 10-digit run inside is rewritten to [PHONE]
False positiveorder 1234567890 shippedorder [PHONE] shipped
NameAnanya RaoNot caught
Spaced digits98765 43210Not caught
Same user, same keyu-42 twiceSame pseudonym
Different user, or different keyu-43, or another keyDifferent pseudonym
  • Pattern matching catches formats, not meaning. Names and unknown key formats slip through, ten-digit order ids look like phone numbers, and a partial match can leave the rest of a secret in the trace. Treat redaction as one layer, with access limits and retention.
  • Store the keyed pseudonym instead of the user id. To honour a deletion request, recompute it from the user id and delete matching traces. Keep the key out of the trace store.

Check yourself

Check: a deletion request

A user asks for their data to be deleted. Engineering deletes their account rows and confirms completion. Six weeks later a support engineer finds the user’s prompts in three other places. Where would you look, and what design would have prevented this?

Answer

Look in the trace store, any response or semantic caches, exported evaluation datasets and golden-set copies, plus backups per your retention rules. The prevention is a policy applied everywhere: store a keyed pseudonymous id so records can be found and deleted, redact on write, set retention periods, and keep raw traces out of shared datasets. OWASP advises you to “maintain clear policies about data retention, usage, and deletion”. Legal specifics depend on your jurisdiction.

Source5 LLM02:2025 Sensitive Information Disclosure

Concept

Common mistakes

  • Logging only final answers. You cannot separate retrieval from generation.
  • No version fields. “What changed?” becomes a guess.
  • Trusting one average score. Read per slice, with noise in mind.
  • Treating feedback clicks as the quality signal. They are sparse and unrepresentative.
  • Alerting on numbers from a blog instead of your own baseline.
  • No privacy policy for traces, or copying raw traces into shared datasets.
  • Never feeding failures back into the golden set.

Summary

Recap

  • LLM systems need tracing (flight recorder) and an offline eval gate (test rig).
  • Record versions, retrieved ids and scores, tokens, latency, cost and outcome signals per request.
  • Online monitoring is live but noisy; offline evaluation catches regressions before users do. Neither replaces the other.
  • Read results per slice and remember small sets are noisy.
  • Alert on change from your own baseline, and treat traces as sensitive: redact, restrict, expire.
  • Feed bad production cases back into the golden set.

References

References & Sources

  1. Demystifying evals for AI agents (opens in a new tab)

    Mikaela Grace, Jeremy Hadfield, Rodrigo Olivares, Jiri De Jonghe2026Article

    Used for Evals before launch and monitoring after launch as layers; starting with 20 to 50 tasks drawn from real failures; model graders need calibration.

  2. OpenTelemetry GenAI Semantic Conventions (opens in a new tab)

    OpenTelemetry2026Specification

    Used for GenAI semantic conventions (spans, metrics, events) now live in this repository; Development status; attribute names such as gen_ai.request.model and gen_ai.usage.input_tokens; content attributes are opt-in and flagged as possibly sensitive.

  3. Your AI Product Needs Evals (opens in a new tab)

    Hamel Husain2024Article

    Used for Looking at traces, cheap feature-scoped tests run on every change, aligning an LLM judge with humans (and not trusting raw agreement on imbalanced classes), and failures feeding new tests.

  4. Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena (opens in a new tab)

    Lianmin Zheng, Wei-Lin Chiang, Ying Sheng, Siyuan Zhuang, et al.2023NeurIPS 2023 Datasets and Benchmarks TrackPaper

    Used for Strong LLM judges agree with human preferences over 80 percent of the time in the paper's setting, with position, verbosity and self-enhancement biases.

  5. LLM02:2025 Sensitive Information Disclosure (opens in a new tab)

    OWASP GenAI Security Project2025Documentation

    Used for Least-privilege access and clear retention, usage and deletion policies among mitigations for sensitive information disclosure.