AI State of the Art
MLOps/LLMOps/28 min
Section 201

Observability: Seeing What Happened in the Chain

Listen as a podcast →

The problem: the answer is bad, but where?

An application built on a language model is almost never a single call. It is a chain: retrieve documents, assemble a prompt, call the model, parse the answer, maybe call a tool, and repeat. When the final answer is bad, the fault can lie in any link, and the faulty link is almost never the suspected one.

The useful distinction is this. Classic monitoring answers "is the service up?": availability, latency, error rate. Observability answers "why did it say that?": which documents were retrieved, which exact prompt was sent, how many tokens were burned, which version was running.

The analogy: knowing the car is moving, versus understanding why it drinks fuel and takes the wrong road.

The three pillars, and which one is specific to models
  1. The trace: a request's full journey through every component.
  2. The metrics: latency, cost, tokens, error rate.
  3. The evaluation: a quality score attached to the answer, from a model judge or from the user.

The first two predate language models and appear unchanged in any distributed system. The third is specific to the field, because the output is neither right nor wrong in a program's sense: no error code ever says the answer was hollow.

The trace: a tree, not a list

A trace is the end-to-end record of one request. It is made of spans, the word means an interval of time, and the usage stuck: a span is a step, with a start, an end, and whatever you attach to it.

The thing to grasp is that spans are nested, not sequential: the model call sits inside the generation step, which sits inside the whole request.

Diagram of a single trace containing a tree of spans. A root span covers the full duration, beneath it two child spans, themselves followed by shorter spans. An arrow marking a new thread moves from a red-coloured group of spans to a second green-coloured group nested lower down.
The structure of a trace. The root span covers the whole request; each child span is a sub-step nested inside it; the width of each bar is its duration. That nesting is what makes it readable at a glance: you see which step eats the time, and which parent step it belongs to. A flat list of timestamped events would hold the same information and be unreadable.Source : Gigi Sayfan, The Gigi Zone

A typical chain gives this tree:

  • User request, the root span
    • Retrieval, querying the vector store
    • Prompt assembly, inserting documents and history
    • Model call, almost always the longest span
    • Parsing, extracting data from the answer
    • Tool call, to an external interface or a database

What a span must capture

  • Input and output, in full. For a model-call span, that means the complete prompt and the complete answer. This is what separates model observability from classic monitoring: elsewhere you record that a call happened; here you record what was said.
  • Duration, to find bottlenecks.
  • Technical context: which model, which version, which temperature, which limits. Version is the field everyone omits and everyone needs three months later.
  • Token counts, input and output separately, which determine cost.
  • Errors, with message and code.

The questions a trace answers

This is where the value shows, because each diagnosis points at a different link:

SymptomWhat the trace revealsWhere the fault really is
Off-topic answerThe retrieved documents were not about the topicRetrieval, not the model
Fabricated answerThe context did not hold the requested informationThe corpus, or retrieval
High latencyThe prompt sent ran to tens of thousands of tokensPrompt assembly
Rising costThe system prompt doubled in length at the last deployAn unmeasured change

The first two rows carry the main lesson: most bad answers from a document-grounded system are not model defects. Without traces you blame the model and switch vendor, which fixes nothing. It is the same split described in RAG evaluation, which measures retrieval and writing separately.

The standard underneath the tools

Before the products, know the layer beneath, because that is the durable part.

OpenTelemetry is the open instrumentation standard, long used well beyond artificial intelligence: it is what defines traces and spans across the software industry. Standardisation work for generative AI is under way, with naming conventions covering spans, metrics and events, including for common model providers. Those conventions are still evolving: the principle is settled, the exact attribute names should be checked in the documentation before being quoted.

What this changes, very concretely: if your application emits traces in the standard format, switching observability tools does not require re-instrumenting the code. You redirect the export. It is the most durable selection criterion on this page, and the one that never appears in comparison tables.

The platforms

Three names recur. What follows describes what they do, not which is best, that depends entirely on your dominant constraint, and products change.

LangSmith

Built by the makers of LangChain. Automatic tracing if the application is built on LangChain, client-library tracing otherwise; span-tree visualisation with each step's content; search and filtering on metadata.

Screenshot of the LangSmith interface. On the left, the span tree of a trace: an assistant span of 1.63 seconds showing 55 tokens and a cost under 0.0001 dollars, containing a get_context span and a ChatOpenAI span of 1.58 seconds. On the right, the detail of the selected span with its Feedback, Input, Output and Attributes tabs, and the JSON content of the input and output.
A real trace. On the left the span tree, each annotated with duration, token count and cost. On the right, the exact content that entered and left the selected step. That visibility into content, not just timings, is what separates model observability from classic monitoring, and it is also what makes it a data file to be treated as one.Source : LangSmith documentation (LangChain)

The most useful mechanism of such a platform is not the display but the trace-to-evaluation loop: spot a problematic trace in production, add it to the evaluation set with the expected answer, and it becomes a permanent test case. After a few months, the evaluation set reflects the service's real failures rather than the cases imagined at the start. That is the mechanism described in building your own evaluation, and observability is what feeds it.

Arize and Phoenix

Arize is a machine-learning observability platform with one distinctive angle: analysis of embeddings, the numeric representations of texts (see text embeddings). Arize maintains Phoenix, an open-source, self-hostable version.

Screenshot of a trace detail view in Phoenix. On the left, the span tree: a query span of 4.70 seconds, a retriever span of 0.72 seconds, a synthesize span of 3.98 seconds and an llm span of 641 tokens. On the right, the detail of the retriever span with the question asked and the list of retrieved documents, each with its similarity score and its text.
The retrieval span, opened. You read the query sent to the vector store, then each document returned with its similarity score and full content. This is the view that settles the commonest question about a document-grounded system: did the bad answer come from the model, or from the documents it was handed? Here the answer is readable in ten seconds.Source : Arize AI (Phoenix blog)
Projecting embeddings to see the holes in your corpus

Embeddings live in a space of hundreds of dimensions, which cannot be drawn. Projection techniques (t-SNE and UMAP are the two commonest) flatten them onto a plane while roughly preserving proximity: what was close stays close, what was far stays far.

Two defects then become visible that no metric reports. Clusters of user questions with no nearby document: the topics your corpus says nothing about, and on which the system invents. Documents nothing ever retrieves: content weighing down the index without ever being used.

One methodological caveat: these projections distort. Two points adjacent on the picture are probably adjacent in the original space, but distances read off the screen carry no quantitative meaning. It is a tool for finding where to look, not for measuring.

Langfuse

Open source, self-hostable or available as a managed service. Tracing through a client library or the common integrations, scores attachable to traces, prompt management, evaluation sets built from traces, cost and latency dashboards.

Its distinguishing argument is not functional but legal: traces never leave your infrastructure. The next section explains why that carries more weight than it looks.

The table, in verifiable facts

Tool comparison tables age fast and ratings like "excellent" cannot be checked. Here are only the structural characteristics, the ones that actually decide:

CharacteristicLangSmithArize / PhoenixLangfuse
Distribution modelManaged, proprietaryManaged, plus open-source PhoenixOpen source, plus a managed offer
Self-hostingNoYes, via PhoenixYes
Projected embedding analysisNoYes, its distinctive featureNo
Built-in prompt managementYesNoYes

In most real cases the deciding criterion is none of these: it is whether trace data may leave the company. That question alone settles half the table.

Traces are a personal-data file

This is the most important point on the page for a legal reader, and the one technical documentation covers in a single line.

A trace holds the complete prompt and the complete answer. The complete prompt holds everything the user wrote, plus every document attached to it. In other words, the trace holds everything the system saw.

Four consequences, in the order they arise:

  1. It is a processing of personal data (PII) as soon as users are identifiable. Lawful basis, purpose, notice to data subjects, retention period: all of it applies.
  2. Sending traces to a third party is a transfer. To a service hosted outside the European Union, it is an international transfer with its own regime. The choice between a managed platform and self-hosting is therefore not just a convenience trade-off.
  3. A retention period must be decided. A trace is useful for a few weeks of diagnosis; by default it is kept forever, because nobody configures a purge.
  4. Redaction must happen before export, not in the viewing interface. Masking on display achieves nothing: the data has already left and been stored.

See data governance for the general framework.

The metrics, and how to read them

Why latency is never read as an average

An average hides exactly what you are looking for. If ninety-nine requests take one second and the hundredth takes thirty, the average is 1.3 seconds, a reassuring figure describing a service where one user in a hundred waits half a minute.

So you read percentiles. The 50th percentile, P50, is the value half the requests beat: the typical experience. P95 is the value 95% of requests stay under; P99, the value 99% stay under. Those two describe the bad days, and they are what produce complaints.

On this kind of application the P50-to-P99 gap is usually wide, for an intrinsic reason: response time depends on how many tokens are generated, and a long answer mechanically takes longer than a short one. A high P99 therefore often signals a population of requests that trigger long answers, not an outage.

What to track

  • Latency, as P50, P95 and P99. And separately time to first token, which is what the user perceives as responsiveness, distinct from total duration.
  • Cost, per request, per user, per day, with anomaly alerting. See cutting the bill.
  • Quality, from automatic scoring of a sample and from explicit user feedback.
  • Technical error rate, distinct from the bad-answer rate: a service can return 200 on everything and still talk nonsense.
  • Similarity scores of retrieved documents, a leading indicator of drift in the corpus or in the queries. See monitoring and drift.

Two engineering constraints people meet too late

Export must never block

Tracing must be invisible to the user. Modern libraries buffer traces in memory and ship them in batches in the background. The property to demand is explicit: if the observability service goes down, the application keeps running and loses traces. The reverse (an application that stops because its measurement tool is unavailable) has happened, and it is an outage caused by the tool meant to diagnose outages.

Tracing everything is expensive

A full trace weighs several times the prompt and answer combined. On high-traffic services, trace storage becomes a budget line of its own, and export consumes bandwidth.

Hence sampling: only a fraction of traffic is retained in full. The rule that works layers three strata, a random sample of ordinary traffic, all requests that errored or ran abnormally slow, and all requests that received negative feedback. You keep every interesting case and only a share of the routine ones.

One consequence to know: a service sampling at a low rate cannot later retrieve the trace of a specific request a user complains about. If that capability is required (for a complaint, an audit, a contractual obligation) it is decided when the sampling is configured, not afterwards.

Why it matters

The module's usual anchor applies here too. Recording execution steps in a tree of spans is standard practice, standardised by OpenTelemetry long before language models and carried over unchanged.

What can rise above that lives in the automatic decisions taken from the traces: the mechanism that chooses which to keep based on an anomaly signal rather than at random; the one that automatically feeds an evaluation set from observed failures; the one that pins a quality regression to a specific version change; the one that detects a bad answer with no user having complained. Faced with such a description, the question to ask is simple: what does the system do with the trace, beyond displaying it?

Check your understanding0 / 5

1. A document assistant gives off-topic answers. What does the trace most often reveal, according to the page?

2. Why does the page treat a trace as a file of personal data?

3. 99 requests take 1 second, the hundredth takes 30 seconds. Why does the page forbid reading latency as an average?

4. Tracing all traffic is expensive. Which sampling rule does the page recommend?

5. The observability service goes down. What should happen on the application side, according to the page?