Correlating Logs, Metrics, and Traces
Unify telemetry by correlating structured logs, metrics, and traces for fast incident diagnosis.
The Three Pillars Problem
Observability rests on three signal types, each answering a different question:
- Logs — discrete events: what happened at a point in time.
- Metrics — aggregated numbers: how much / how often over time.
- Traces — causal request flow: where time was spent across services.
During an incident, looking at each pillar in isolation is slow. You see a latency spike in a metric, but you cannot jump to the exact logs or the slow span. The goal of this lesson is correlation: stitch the three together so one signal links directly to the others, collapsing diagnosis time from minutes to seconds.
The Glue: trace_id and span_id
The key that unifies all three pillars is the trace context propagated by OpenTelemetry / Micrometer Tracing. Two identifiers matter:
traceId— a unique id for the entire request as it crosses services.spanId— a unique id for one unit of work inside that trace.
If every log line, every metric exemplar, and every span carries the same traceId, a single id lets you pivot between pillars. In Spring Boot 4, Micrometer Tracing automatically places these ids into the SLF4J MDC (Mapped Diagnostic Context), so your logs inherit them with zero per-line code.
All lessons in this course
- Context Propagation and Span Instrumentation
- Circuit Breakers and Bulkhead Isolation
- Rate Limiting, Retry, and Time Limiters
- Correlating Logs, Metrics, and Traces