RELIABILITY, SECURITY & CASE STUDIES · SUBTOPIC
Metrics, Logs & Distributed Tracing
Combine Prometheus metrics, structured JSON logs, and OpenTelemetry trace spans.
BeginnerPart of Observability, Logging & Tracing
Subtopics in Observability, Logging & Tracing (2)
In plain words
Metrics are your car dashboard (speed & engine temperature). A trace is GPS showing which highway exit had the traffic jam. Logs are the dashcam recording what happened right there.
Think of it like…
Car gauges (Metrics), GPS route timeline (Trace), dashcam recording (Logs).
Loading interactive diagram
Loading interactive exercise
Theory & how it works
The #1 Metrics Pitfall: High-Cardinality Labels
Never put user_id or request_id as a Prometheus metric label! Millions of unique users create millions of time series and crash your monitoring server. Keep IDs in Logs and Traces, and keep Metrics labels low-cardinality (service, route, status_code).
Key points & practical guide
Summary checklist
- Monitor RED metrics (Rate, Errors, Duration p50/p99)
- Use head/tail sampling (e.g., 100% of errors, 1–5% of normal traces) to control cost
- Keep
user_id/order_idout of metric labels - put them in structured logs
When to use it
- Every production backend, especially microservices and queues
Watch out for
- Logging PII (passwords, credit cards, tokens) in plain text logs
Quick check
Loading quiz