Observability and SREVol. 9 · Part IX
0 / 0

Shelves / Observability and SRE

OB·00

Start Here: Seeing Inside a Running System

For readers who have debugged with print statements but never operated a service: why production needs observability, the three signals (logs, metrics, traces) produced by two small instrumented services and used together to find a slow request, the vocabulary of the volume, and how to study it.

9 topics · ~5 min read · 10-question quiz
Updated Suggest a correction

Start here: how to use this volume

Two reading paths

This volume is about running software in production and knowing what it's doing: logs, metrics, traces and OpenTelemetry; SLOs and error budgets; incident management; reliability patterns; and performance engineering. Every chapter has the same shape: a plain-language Start here section with small, verified experiments; a How deep to go ladder; the full-depth sections; a Lab of real measurements; and a Revision sheet.

  • New to operations? Read this chapter, then the chapters in order. The experiments use free tools you can run on a laptop: Prometheus 3.15, Jaeger 2.14, the OpenTelemetry Collector 0.149, and the OpenTelemetry Python SDK 1.45.
  • Experienced? Skip this chapter. In each chapter read the revision sheet first, take its quiz, then use How deep to go to choose the sections and lab experiments to study.

Mastery levels

Every chapter uses the same six levels:

Level Name You can… Example for tracing
L1 Recognition define it and spot it "that's a span inside a trace"
L2 Working use it correctly instrument a service and follow a request in Jaeger
L3 Internals explain why it works explain context propagation and sampling trade-offs
L4 Debugging diagnose failures find why traces break at one service boundary
L5 Design choose between approaches design a telemetry pipeline and sampling policy for a platform
L6 Production run it at scale operate observability for hundreds of services within a budget

Why production needs observability

You can't attach a debugger to production

On your laptop you can pause a program, inspect variables and re-run a failing case. In production, thousands of requests flow through many services on many machines, the failing request has already gone, and you can't stop the system to look. You can only understand it through what it emits while running. Observability is the ability to answer questions about a system's behaviour from those outputs, including questions you didn't think of in advance ("why are biryani orders slow for customers in one area since 7 pm?").

The three signals

Signal What it is Good for Example
Logs Timestamped records of discrete events Details of what happened in one place {"route": "/cook", "status": 200, "duration_ms": 905.7, "trace_id": "d589…"}
Metrics Numbers aggregated over time Trends, alerting, dashboards, cheap at any traffic p99 latency of /order = 944 ms
Traces The path of one request across services, as timed spans Where time went and which service failed kitchen: SELECT stock … 900 ms

(Profiles, continuous CPU and memory profiling, are increasingly treated as a fourth signal.)

Finding a slow request with all three

Two small Python services: orders receives an order and calls kitchen, which checks stock in a (simulated) database. Both are instrumented: a JSON log line per request with the trace ID, a Prometheus latency histogram, and OpenTelemetry spans sent to Jaeger. Sometimes the stock query for biryani is slow. 400 orders later:

Text
400 orders sent; client-side: median 21 ms, slowest 922 ms
1) METRICS (Prometheus): latency by service
   p50 /cook        18 ms
   p50 /order       18 ms
   p99 /cook       944 ms
   p99 /order      944 ms
   share of /order requests under 500 ms: 91.0%

Metrics told us that something is wrong and how much: half of requests take under 20 ms, but the slowest 1% take nearly a second, and 9% of orders take over half a second. They're cheap and perfect for alerting, but they can't say which requests or why.

Text
2) TRACES (Jaeger): find a slow one, see where the time went
   trace d58927abf3a3e0fc6c7540ff6c48f76f (dish=biryani):
        0.0 ms    909.6 ms  orders   GET /order
        0.0 ms      2.2 ms  orders   validate order
        2.3 ms    907.1 ms  orders   call kitchen
        3.2 ms    905.8 ms  kitchen  GET /cook
        3.2 ms    900.1 ms  kitchen  SELECT stock FROM ingredients
      903.5 ms      5.2 ms  kitchen  reserve ingredients

A trace of one slow request showed where: 900 of its 910 milliseconds were one database query in kitchen, two services away from where the user waited. The trace crossed the service boundary because orders passed its trace context to kitchen in a traceparent HTTP header.

Text
3) LOGS: every line from that request, in both services, joined by trace_id
   orders   /order  status=200 duration_ms=909.6 trace_id=d58927abf3a3…
   kitchen  /cook   status=200 duration_ms=905.7 trace_id=d58927abf3a3…

Logs sharing the trace ID gave the details of that exact request in each service. Together: metrics to detect, traces to locate, logs to explain. That workflow, and making it cheap and reliable at scale, is what this volume teaches.

From signals to reliability

Observability serves a goal: services that are reliable enough for their users, at a sustainable cost. The rest of the volume builds on the signals: SLOs turn metrics into a promise and an error budget (chapter 102), incident management handles the times the promise breaks (103), reliability engineering designs failure out (104), and performance engineering keeps it fast as load grows (105).

How to study observability

A routine that works

  1. Instrument something you wrote: add structured logs, a latency histogram and traces to a small service.
  2. Break it and find the break using only the signals: inject latency, errors, a crashed dependency.
  3. Write the question first ("which dependency is slow?"), then find which signal answers it.
  4. Watch the costs: count log bytes, metric series and spans per request.

Warm-up exercises

  1. Take a service you know and list what it logs per request. Could you find one customer's request?
  2. Name the four "golden signals" for a web service and how you'd measure each.
  3. Run Prometheus and scrape its own /metrics; graph rate(prometheus_http_requests_total[1m]).
  4. Run Jaeger and send one span from the OpenTelemetry Python SDK.

Glossary

  • Telemetry: data a system emits about itself.
  • Structured log: a log record with named fields (JSON), not free text.
  • Metric: a numeric measurement aggregated over time, identified by a name and labels.
  • Histogram: a metric counting observations in value buckets, for percentiles.
  • Trace / span: a request's journey / one timed operation within it.
  • Context propagation: passing trace identifiers between processes (W3C traceparent).
  • SLO: a target for a service's reliability as users experience it.
  • OpenTelemetry: the vendor-neutral standard and SDKs for producing telemetry.