Distributed systems / Observability

Observability

A checkout turns slow at 14:05. Follow how a metric, a trace and four log lines, read together, lead from the symptom to the cause without opening the system.

Beginner7 steps~6 min
Service — one running part of the system
Metric — a number recorded over time
Trace — one request, timed span by span
Log — a timestamped event, in words
// THE SHORT VERSION

In 30 seconds

Observability is how well you can work out what is happening inside a system by looking only at what it emits.

Three signals do most of the work. Metrics are numbers over time and show that something is wrong. Traces follow one request across services and show where. Logs are timestamped events and show what happened.

Monitoring checks for failures you thought of in advance. Observability is what lets you investigate the ones you did not.

Observability, step by step

STEPS01 / 07

An invented incident with round numbers. Real systems add other signals (events, profiles), and the line between monitoring and observability is drawn differently by different teams.

STEP 01 / 07 A slow checkout
THE MATH
checkout takes 4.2 s usual: 0.2 s why?
  1. Step 1: A slow checkout. A shop’s checkout is built from three services. Since 14:05 it answers in 4.2 seconds instead of 0.2. From outside you see only requests going in and responses coming out, not which part is slow or why.
  2. Step 2: Three kinds of output. Observability is how well you can work out a system’s inner state from what it emits. The term comes from control theory. In software the outputs are mostly three signals, each written by the services as they run.
  3. Step 3: Metrics: something is wrong. A metric is a number recorded at regular intervals. Here it is p99 latency: 99 of every 100 checkouts finish faster than this. It jumps from 0.2 s to 4.2 s and trips an alert. Metrics are cheap and show that something broke and when, but not where.
  4. Step 4: Traces: where it is slow. A trace follows one request through every service it touches and times each stretch, called a span. This slow checkout spent 80 ms in CART and 4000 ms in PAY, almost all of it in two calls to an outside bank. Now you know where to look.
  5. Step 5: Logs: what happened. A log is a timestamped record of one event, written by the code. Filtering PAY’s logs by the trace id shows the story: the bank did not answer within the 2000 ms limit, so PAY gave up, retried, and the second call took 1900 ms.
  6. Step 6: Linked, they explain it. Each signal alone is a fragment. The chart gave a time, the time led to a slow trace, and the trace id led to the right log lines. That chain only works if every signal carries shared context such as timestamps and trace ids.
  7. Step 7: Known and unknown failures. Monitoring watches for failures someone predicted and wrote a rule for. Nobody wrote a rule for “one bank is slow”. Because each request was recorded with details such as which bank it used, a brand new question can be asked of the data already collected.
VALUES SO FAR
checkout4.2 ssymptom
p99····metric
since····metric
trace····id
PAY span····trace
timeout····log
retry····log
cause····finding

Spotted a mistake on this page?