Skip to content
AI.info

MLOps

Observability for ML Systems

Design logs, metrics, traces, events, and decision records that support diagnosis across service, data, model, and workflow layers.

By the end you can

Example

Cardinality collapses the monitoring system

Every metric gets a request-level identifier attached. What happens next is arithmetic, and the vendor publishes it. Google Cloud Monitoring states that total cardinality is the product of metric and resource cardinality: “If you have a metric with cardinality of 1,000, and a resource with cardinality of 100, and if every label value appears, then you have 100,000 time series (1,000×100)”. A request ID is not a dimension of cardinality 1,000. It is a new label value for every call. The multiplication has no upper factor at all.

Two independent organisations publish the rule against it, an open-source project and a commercial vendor, in almost the same words. Prometheus puts it in a CAUTION note: “Remember that every unique combination of key-value label pairs represents a new time series, which can dramatically increase the amount of data stored. Do not use labels to store dimensions with high cardinality (many different label values), such as user IDs, email addresses, or other unbounded sets of values.”

Neither of them is describing an edge case. They are describing what a request ID does to a metric store.

  • High-cardinality labels: Customer, request, feature, and trace IDs create millions of time series. Both organisations name the same offenders, and neither hedges. Google Cloud Monitoring: “Do not use high-resolution values like timestamps, any kind of unique identifier, user IDs, IP addresses, unparameterized URLs, and so forth, for metric labels.”
  • Cost and latency: Metric queries become expensive during the incident they should diagnose. There is a ceiling as well as a bill. Google Cloud Monitoring's quotas allow 200,000 active time series from custom metrics per monitored resource, and 1,000,000 for Prometheus-sourced metrics. A single request-ID label crosses either number on an ordinary afternoon.
  • Privacy exposure: Raw identifiers appear in broad monitoring access. Customer and user IDs end up in label sets readable by anyone holding a dashboard, inside a store governed as infrastructure rather than as product data.
  • Lost correlation: Operators still need logs and traces for individual requests. The label explosion bought volume, not the path through one call. The identifiers that would open that path are now scattered across time series nobody can query quickly.
  • Repair: Keep bounded metric dimensions and correlate sampled exemplars to detailed traces. The exemplar is specified, not improvised. OpenMetrics defines it — “Exemplars are references to data outside of the MetricSet. A common use case are IDs of program traces.” — and budgets it: “The combined length of the label names and values of an Exemplar's LabelSet MUST NOT exceed 128 UTF-8 character code points”, while “Ingestors MAY discard exemplars”. Prometheus, behind its opt-in exemplar-storage feature flag, reports that “An exemplar with just a trace_id=<jaeger-trace-id> uses roughly 100 bytes of memory via the in-memory exemplar storage”. A hundred bytes buys the individual request that a million time series could not.

More telemetry can make a system less observable

A prediction service emits thousands of metrics with model ID, customer ID, feature name, and request ID as labels. The monitoring backend becomes expensive and slow. Operators still cannot connect a bad decision to the feature values and policy used.

Observability is the ability to ask useful questions about internal state from external evidence. It requires correlation, semantics, and bounded telemetry—not logging everything.

Most of an ML system is not the model, and that got a number at the start of the MLOps literature. Sculley and nine co-authors published “Hidden Technical Debt in Machine Learning Systems” in 2015. A mature system, they estimated, “might end up being (at most) 5% machine learning code and (at least) 95% glue code”. Their caption to Figure 1 says it as a picture: “Only a small fraction of real-world ML systems is composed of the ML code, as shown by the small black box in the middle. The required surrounding infrastructure is vast and complex.”

The same paper names monitoring itself as a system-level debt, and its warning is the one this lesson exists to answer: “Even monitoring ML system behavior may prove difficult without careful design”. If at most five percent of the system is the model, telemetry aimed only at the model is aimed at the wrong ninety-five percent.

Comparison

Operational and analytical telemetry have different retention

The most useful detail depends on the question and the time horizon. Hot operational evidence is queried in minutes and thrown away. Warm diagnostic evidence is sampled, access-controlled, and kept long enough to reconstruct a cohort. Cold audit evidence is a narrow, deliberate schema, kept because someone may contest a decision.

For the cold tier, “retention follows policy” now has article numbers behind it. The EU Artificial Intelligence Act — Regulation (EU) 2024/1689, of 13 June 2024 — makes the record compulsory for high-risk systems: “High-risk AI systems shall technically allow for the automatic recording of events (logs) over the lifetime of the system.” (Article 12(1)). Article 19(1) sets the floor for keeping them. Providers must retain the automatically generated logs “for a period appropriate to the intended purpose of the high-risk AI system, of at least six months”, unless other Union or national law provides otherwise.

Six months is not a storage-budget decision for a high-risk system. It is the statutory minimum. The schema that survives that long is the one an operator will have to defend.

FigureComparison · 3 columns

Hot operational evidence

Recent, queryable signals for detection and incident response.

  • Low latency access
  • Bounded retention
  • High reliability
  • Example: error-rate burn and trace exemplars

Warm diagnostic evidence

Structured samples and aggregates for investigation and model analysis.

  • Longer retention
  • Controlled access
  • Supports cohort reconstruction
  • Example: sampled feature and decision envelopes

Cold audit evidence

Immutable release and decision records required for governance or dispute.

  • Narrow, deliberate schema
  • Retention follows policy
  • Strong integrity controls
  • Example: model and policy identity for a contested decision

ML decisions need an evidence envelope

A distributed trace can show the path through authentication, feature lookup, inference, and policy. Metrics summarize rates and distributions. Logs preserve discrete events and context. A decision envelope links these signals to the exact model, feature set, threshold, fallback, and output.

No single signal is sufficient. Correlation identifiers and context propagation allow operators to move from an alert to a trace, then to structured records and affected cohorts.

Correlation has a standard behind it. W3C made Trace Context a Recommendation on 23 November 2021. It defines a traceparent header carrying a version, a trace-id, a parent-id and trace flags. The trace-id is “a 16-byte array”; the parent-id an “8 bytes array identifier”. OpenTelemetry requires the same header and the same field sizes.

The step from a bounded metric down to one individual request is specified too. OpenTelemetry's metrics data model defines an exemplar as “a recorded value that associates OpenTelemetry context to a metric event within a Metric”, one component of which is the optional trace association given as (trace_id, span_id). That pair is the whole bridge. The metric keeps a handful of dimensions. A few sampled points carry the identifiers that open the trace, the logs and the decision record for the call behind the spike.

Visual

Signals answer different operational questions

Collect each signal for the question it answers best. Metrics say how often, how much, and how a distribution moved. Traces say where time and failure went in one request. Logs and events preserve the discrete transition. Decision evidence binds model, features, policy, fallback and outcome together.

The last of those is the one teams discover last and need most, and it was already on the list in 2015. Sculley et al. offered prediction bias, action limits and up-stream producers as starting points for what to monitor. Not model accuracy. The places where a model's behaviour touches the surrounding system that makes up the other ninety-five percent.

FigureHierarchy · 4 levels
  • Metrics

    How often, how much, and how the distribution changes.

    • Traces

      Where time and failure occurred across one request or workflow.

      • Logs and events

        What discrete state transition or error was recorded.

        • Decision evidence

          Which model, features, policy, fallback, and outcome belong together.

Analogy

Observability is a map with zoom levels

Observability is a map with zoom levels. It begins with regional traffic, zooms into one road, and then opens the dashcam record of a specific incident. Metrics, traces, and logs offer those zoom levels, while correlation keeps the location consistent.

Every road on the map was drawn by somebody who decided it was worth surveying. Telemetry that nobody instrumented reads as blank ground. Sampled telemetry draws a thinner road than the traffic warrants. Each extra gauge costs money, latency, and privacy exposure.

The survey has a published price list. Google's Dapper report measured what tracing costs in a web search cluster in April 2010. Trace every request — 1/1 sampling — and average latency rose 16.3%, while throughput fell 1.48%. At 1/1024 the same two measurements moved −0.20% and −0.06%, inside the stated experimental errors of 2.5% and 0.15%. The conclusion: “In practice, we have found that there is still an adequate amount of trace data for high-volume services when using a sampling rate as low as 1/1024.” The first production version sampled one trace per 1024 candidates. Each span averaged 426 bytes, and the collection daemon never used more than 0.3% of one core. The thinner road was the only road they could afford to draw at all.

A decade later the practice was unchanged. A 2022 paper on tracing edge cases in distributed systems records that head sampling is enabled by default in Jaeger with a 0.1% sampling probability, and that some production systems sample as few as 0.001%, citing the Dapper report itself. Its alternative is no free lunch either: “frameworks can trace everything and later keep only the interesting edge-case traces (tail sampling), but this has high overheads on the traced application and enormous data ingestion costs”.

Useful observability lets an operator move from population signal to causal path without losing identity.

Key idea

Observability data can become a shadow dataset

Features, prompts, images, text, embeddings, and outputs may contain personal or confidential information. Logging them by default can create a less-governed copy of production data.

Use minimization, redaction, hashing where appropriate, role-based access, sampling, retention limits, and purpose review. A trace should identify the evidence path without becoming an uncontrolled archive of user content.

This is documented, and it has been fined. On 21 March 2019 Meta disclosed that a routine security review had found user passwords stored in readable form inside its internal data storage systems — hundreds of millions of Facebook Lite users, and tens of millions of other Facebook users. An update of 18 April 2019 extended the finding to the telemetry itself: “Since this post was published, we discovered additional logs of Instagram passwords being stored in a readable format.”

On 27 September 2024 the Irish Data Protection Commission fined Meta Platforms Ireland €91 million over the same events, recording infringements of GDPR Articles 33(1), 33(5), 5(1)(f) and 32(1). Deputy Commissioner Graham Doyle put the standard in one line: “It is widely accepted that user passwords should not be stored in plaintext, considering the risks of abuse that arise from persons accessing such data.” Nobody designed a password store inside the logs. The logs are simply where the values ended up, and the regulator priced the difference between a product datastore and a shadow one at ninety-one million euro.

Telemetry must be designed with the same privacy and security discipline as product data.

Steps

Design telemetry from incident questions

Begin with what an operator must decide, then choose the minimum evidence: list the diagnostic questions, assign each one a signal, define the correlation identifiers that connect them, bound detail and retention, then test the investigation.

Step four has measurements behind it rather than instinct. Dapper priced the choice: 16.3% added average latency at 1/1 sampling against −0.20% at 1/1024, with spans averaging 426 bytes. The sampling rate you pick is a figure you can defend in a design review instead of a preference.

Step five is published doctrine at two large operators. Google's The Site Reliability Workbook (2018) describes company-wide Disaster Recovery Testing (DiRT) alongside smaller Wheel of Misfortune exercises, and states the rule for them: “Teams respond to the controlled emergency as if it were a real emergency.” AWS numbers the same practice. REL12-BP05 of the Well-Architected Framework Reliability Pillar, “Conduct game days regularly”, instructs: “To help you reproduce real-world scenarios where system components or services may fail unexpectedly, inject simulated faults as a game day exercise.” The exercise runs in a replica environment. Teams observe system behaviour with CloudWatch and X-Ray while the fault is live, and the same document's REL06-BP07 requires end-to-end tracing of requests through the system — the thing the game day is watching. The drill tests the telemetry, not only the responders.

FigureProcess · 5 steps
  1. 1. List diagnostic questions

    Examples: which cohort, dependency, model, or feature changed?

  2. 2. Assign the signal

    Use metrics for rates, traces for paths, logs for events, and decision records for attribution.

  3. 3. Define correlation

    Propagate trace, request, release, entity, and decision identifiers safely.

  4. 4. Bound detail and retention

    Control cardinality, sampling, sensitive fields, access, and cost.

  5. 5. Test the investigation

    Run an incident drill and measure whether evidence supports the required decision.

A dashboard is the last step, not the first

Dashboards should implement a diagnostic model that the team already understands. Adding charts without a question creates noise and encourages metric ritual.

Review telemetry after incidents. Which evidence arrived too late, which fields were unnecessary, and which correlation broke?

Google's SRE book offers a default for that diagnostic model: “The four golden signals of monitoring are latency, traffic, errors, and saturation”. The advice that follows is blunt: “If you can only measure four metrics of your user-facing system, focus on these four.” Four is a smaller number than the thousands of labelled series the case section began with. It is also the number a team can actually reason from during an incident.

Key takeaways