Overview
Observability is the ability to understand what a system is doing internally from the data it produces, so you can answer new questions about failures without shipping new code. Its three pillars are metrics (numeric time series such as request rate and latency), logs (timestamped event records), and traces (the path of one request across services, broken into spans).
Good observability ties these together with shared context (trace IDs in logs, exemplars in metrics), defines SLIs and SLOs for user-facing behavior, alerts on symptoms users feel rather than every cause, and supports fast debugging with dashboards and distributed tracing. OpenTelemetry has become the standard for instrumenting applications across vendors.
The dashboard gauges (metrics) show speed and fuel at a glance. The trip log (logs) records notable events. The GPS track (trace) shows exactly which roads one journey took and where it slowed down.
When to use it
- Every production service.
- Debugging latency and errors across microservices.
- Defining SLOs and alerting.
- Capacity planning and performance tuning.
Where it shows up in interviews
Recognize it when: how will you know it is working?
- Design monitoring for a payment system
- Design an observability platform
Recognize it when: requests are slow, but which service?
- Diagnose slow checkout in microservices
Where it is used in real software
CNCF standard APIs, SDKs, and collector for metrics, logs, and traces, supported by most vendors.
Widely used open-source metrics and dashboards.
Tracing backends for following requests across services.
Key terms
- Metrics
- Aggregated numbers over time (counters, gauges, histograms).
- Logs
- Discrete event records, ideally structured JSON.
- Traces and spans
- Request path across services; each span is one operation.
- RED / USE
- Rate, errors, duration for services / utilization, saturation, errors for resources.
- Cardinality
- Number of unique label combinations; high cardinality is costly for metrics.
How it works, step by step
- 1Instrument with OpenTelemetry
Auto-instrument HTTP, DB, and messaging clients.
- 2Emit RED metrics per endpoint
Rate, errors, latency histograms.
- 3Use structured logs with trace IDs
Correlate logs with traces.
- 4Propagate trace context
traceparent header across services and messages.
- 5Define SLOs and alert on burn rate
Page on user impact, not on every blip.
STEP 1The trace starts at the gateway; total latency is 420 ms.
Three pillars compared
What each is best at
| Signal | Answers | Cost driver | Example |
|---|---|---|---|
| Metrics | Is something wrong? How much? | Label cardinality | p99 latency of /checkout = 850 ms |
| Logs | What exactly happened? | Volume | payment declined: insufficient_funds |
| Traces | Where is the time going? | Sampling rate | Payments span 360 ms of 420 ms |
NOWSignal: Metrics | Answers: Is something wrong? How much? | Cost driver: Label cardinality | Example: p99 latency of /checkout = 850 ms
Metrics detect, traces locate, logs explain. Linking them via trace IDs makes debugging fast.
Implementation
import { NodeSDK } from "@opentelemetry/sdk-node";import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";import { trace } from "@opentelemetry/api"; new NodeSDK({ serviceName: "checkout", traceExporter: new OTLPTraceExporter({ url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT }), instrumentations: [getNodeAutoInstrumentations()], // HTTP, Express, pg, Redis, Kafka...}).start(); const tracer = trace.getTracer("checkout"); export async function checkout(cartId: string) { return tracer.startActiveSpan("checkout.process", async (span) => { span.setAttribute("cart.id", cartId); try { const result = await processCart(cartId); logger.info({ cartId, traceId: span.spanContext().traceId }, "checkout completed"); // correlated log return result; } catch (err) { span.recordException(err as Error); throw err; } finally { span.end(); } });}Complexity and performance
Tail sampling keeps errors and slow traces.
Avoid user IDs as labels.
Trade-offs
Full logs and 100% traces are expensive at scale; sample traces, sample or aggregate logs, and control metric cardinality.
Too many alerts cause fatigue; SLO burn-rate alerts focus on user impact.
Variants and related techniques
Always-on CPU and memory profiles (Pyroscope, Parca).
Front-end performance and errors from real browsers.
Common mistakes
- Unstructured logs.
Fix: Use JSON with consistent fields and trace IDs.
- High-cardinality metric labels.
Fix: User or request IDs belong in logs and traces, not metric labels.
- Alerting on causes (CPU 80%).
Fix: Alert on symptoms (error rate, latency SLO burn).
- Logging secrets or personal data.
Fix: Redact sensitive fields.
Interview questions
What is the difference between monitoring and observability?
Monitoring tracks known conditions with predefined dashboards and alerts; observability is the broader ability to ask new questions of the system using rich telemetry (metrics, logs, traces) to understand unknown failure modes.
How do you find which service causes slow requests?
Use distributed tracing: each request carries a trace ID across services, and the trace waterfall shows which span dominates latency; then drill into that service's metrics and correlated logs.
Practice problems
| Problem | Difficulty | What it trains |
|---|---|---|
| Define SLIs and SLOs for an API | Easy | User-facing indicators. |
| Instrument a service with OpenTelemetry | Medium | Traces and correlation. |