In brief
Observability is the ability to answer the question of why a system behaves the way it does, based on the data it emits itself. Metrics tell you that something is happening and how often, traces show where in the chain of services the time of a single request goes, and logs explain exactly what happened. In a distributed system they are tied together by a shared trace ID. OpenTelemetry provides one open standard for collecting all three signals, independent of the tool vendor.
Three signals and the questions they answer
Each of the three signals answers a different question, and none replaces the others.
| Signal | Answers the question | Example from a system | Cost |
|---|---|---|---|
| Metrics | Is something happening, and how often? | transfers per second, p95 of authorization time, connection pool utilization | low, numbers collected at regular intervals |
| Traces | Where does the time of this request go? | service activation at an operator: API gateway, product catalog, network system, database | medium, usually sampled |
| Logs | What exactly happened? | an application validation error with the code and the technical customer ID | high at heavy traffic |
A practical diagnosis goes from the general to the specific: an alert from a metric (a rise in p95 or in the error rate), then the traces of slow requests from that time window, and finally the logs from the service where the trace showed the delay. Without traces, the team guesses which of a dozen or so services is to blame.
Metrics: few, but well chosen
Metrics are cheap and fast, so alerting is built on them. The Google SRE book proposes four golden signals for every service: latency, traffic, errors, and saturation. This is a good starting point for every service in a distributed system.
Two rules that save trouble:
- Times as histograms. You collect response time as a histogram, so that you can calculate percentiles for the whole cluster instead of averaging values from individual servers. Why is explained in the article Percentiles instead of averages.
- A limited number of label values. A label with a customer ID or an order number creates a separate data series for every value and can clog the metrics system. Such identifiers go into traces and logs, while metric labels describe small sets: the service, the operation, the response code, the region.
Distributed traces and request context
A trace is a tree of operations (spans) of a single request across many services, with the start time and duration of each. For services to add their operations to the same trace, the trace ID must pass through every call. The W3C Trace Context standard describes how to pass it in the `traceparent` HTTP header; with communication through queues, the ID goes into the message headers.
An example, explicitly illustrative: service activation at an operator takes 3 s instead of the usual 400 ms. Metrics show a rise in p95 but do not point to the cause. The trace of a single slow request shows that 2.4 s of the 3 s is waiting for a response from the network system, including several repeated retries of the same call. This immediately points to the team and the place in the code.
Traces are more expensive than metrics, so they are usually sampled:
- head sampling decides at the first service whether to record a trace; it is cheap, but it can miss rare, slow requests,
- tail sampling decides after the whole trace has been collected and lets you keep all traces with errors and above a time threshold; it requires buffering traces, e.g. in the collector.
Logs linked to traces
Logs are the most detailed and the most expensive at heavy traffic. To be useful in a distributed system, they must meet three conditions: have structure (e.g. JSON with fields instead of free text), contain the trace and span ID, and not contain data that must not be stored, such as passwords, full card numbers, or excess personal data.
A trace ID in a log lets you go with one click from a slow trace to all the entries from that request, across all services. Without it, diagnosis comes down to searching by time and guessing which entry belongs to which request. You set the level of detail deliberately: in production, errors and business events, details only on demand and for a short time.
OpenTelemetry: one standard for collecting data
OpenTelemetry is an open Cloud Native Computing Foundation project that defines APIs, libraries, and a protocol (OTLP) for collecting traces, metrics, and logs. You instrument the code once, and the data can be sent to different analysis systems without changing the application. For popular languages and libraries there is automatic instrumentation, e.g. an agent for Java applications that records HTTP calls, database queries, and messages without code changes.
A typical setup in a distributed system:
- Applications send data via OTLP to an OpenTelemetry collector running next to them, e.g. in the same Kubernetes cluster.
- The collector enriches the data (service name, environment, version), samples traces, and removes sensitive fields.
- The collector forwards metrics, traces, and logs to the chosen storage and analysis systems.
This separation lets you change the tool vendor without changing applications and keep the sampling rules in one place.
Observability in performance testing
The same observability that production uses should work in the performance test environment. A load test without traces and metrics on the system side ends with a report saying "p95 too high" without the cause. With them, the test result leads straight to a specific service, query, or connection pool, as in the article Database bottlenecks. Production metrics are also the basis of service objectives: how to turn them into SLOs agreed with the business is described in the article SLOs and error budgets. We describe monitoring and cloud for critical systems in the section What we do.
Questions and answers
How does observability differ from monitoring?
Monitoring checks conditions known in advance: whether a service responds, whether the CPU stays below a threshold, whether the error rate is low. Observability lets you answer questions nobody anticipated, e.g. why only activations of one type of service in one region are slow. Monitoring is part of observability, but without traces and linked logs it is not enough in a distributed system.
Does OpenTelemetry replace Prometheus, Jaeger, or Grafana?
No. OpenTelemetry standardizes the collection and transmission of data, not its storage and analysis. Data from OpenTelemetry goes to systems such as Prometheus for metrics or Jaeger for traces and is viewed in, for example, Grafana. The benefit is that you instrument the application once, regardless of the analysis system you choose.
What percentage of traces should I record?
It depends on traffic and the storage budget. At heavy traffic, a small percentage of ordinary requests is enough, provided that traces with errors and very slow ones are kept in full, which tail sampling makes possible. At low traffic, e.g. in an internal system, you can record all traces.
Where do I start with observability in an existing system?
With the four golden signals for each service and a trace ID in the logs. The next step is OpenTelemetry automatic instrumentation for the services on the path of the most important business transaction, e.g. a payment or a service activation, and a collector that gathers the data in one place. You add the remaining services gradually.