Skip to the page

Scaling and running in production · mid

Observability: logs, metrics and traces

Observability means you can explain what your system is doing from the outside: structured logs say what happened, metrics show rates, errors and latency percentiles over time, and distributed traces show where one request spent its time across services.

The notes

What you must know

  • Logs: structured JSON events with a request/trace id. Metrics: numbers over time (requests per second, error rate, p50/p95/p99 latency, event loop lag, memory). Traces: a tree of spans for one request across services.
  • RED for services: Rate, Errors, Duration. USE for resources: Utilisation, Saturation, Errors.
  • Use percentiles, not averages: an average of 200 ms can hide 5% of users waiting 3 s (p95).
  • OpenTelemetry is the standard for instrumenting traces, metrics and logs; context travels between services in the W3C traceparent header. Backends: Grafana stack, Datadog, New Relic, CloudWatch/X-Ray (AWS now recommends OpenTelemetry instrumentation).
  • SLOs and alerts: alert on user-facing symptoms (error rate, p99 latency against an SLO), not on every CPU blip; every alert needs a runbook.
  • Frontend side: RUM and error tracking (Sentry) linked to backend traces with the same trace id.

The red pen

Common traps: mistake → fix

  • Mistake: Average latency is a good health signal

    Fix: averages hide the slow tail; watch p95/p99.

  • Mistake: More logs = more observability

    Fix: without structure, ids and metrics you cannot answer 'why is it slow?'.

Easy to hard

Questions interviewers ask, easy to hard

  1. How do you know your API is healthy in production?
  2. Logs vs metrics vs traces: what does each answer?
  3. Why p99 instead of average?
  4. A request is slow only sometimes. How do you find which service is responsible?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview