Native correlation between metrics, logs, traces, and continuous profiling with eBPF
How to link the four observability signals with trace_id, exemplars, and span metrics, what continuous profiling with eBPF is, and an investigation flow that goes from alert to line of code in minutes.
Observability$ grep trace_id=4bf92f3577b34da6 app.log▍Having metrics, logs, and traces is not the same as having observability. In many incidents, the on-call engineer opens a metrics dashboard in one tab, a log search in another, and a tracing tool in a third, then tries to cross-reference everything by timestamp. It’s slow, imprecise, and depends on whoever knows the system by heart.
Native correlation means each signal carries the keys to reach the others: from the spike on the chart to the trace of a slow request, from the trace to that request’s logs, and from the slow section to the CPU profile that shows the function responsible.
The keys to correlation
| From → To | Key that links the signals |
|---|---|
| Metric → Trace | Exemplars: metric samples carrying the trace_id of a real request |
| Trace → Logs | trace_id and span_id written to every log line |
| Logs → Trace | The same trace_id, clickable in the logging tool |
| Trace → Profiling | Profiles labeled with the span (or with the service and time window) |
| Everything ↔ Everything | Identical resource attributes: service.name, version, environment, pod |
Without consistent resource attributes, none of this works, which is why standardizing with OpenTelemetry comes first.
Logs with trace_id
Logging libraries integrated with OpenTelemetry (log bridges and appenders for Java, .NET, Python, Node.js, and others) add the trace context automatically. The result is a structured log like this:
{
"timestamp": "2026-11-24T21:14:03.512Z",
"severity": "ERROR",
"body": "failed to authorize payment",
"service.name": "checkout",
"trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
"span_id": "00f067aa0ba902b7",
"app.order.payment_method": "card"
}
Free-text logs, with no structure and no trace_id, are the biggest obstacle to correlation. Moving to structured logs is usually the first step with the highest return.
Exemplars: from the chart to the request
A latency histogram tells you the p99 went up, but not which request was slow. Exemplars attach the trace_id of a real request to some of the samples. In Grafana, they show up as dots over the chart; one click opens the trace.
In Prometheus, exemplar storage has to be enabled (--enable-feature=exemplar-storage); the OpenTelemetry SDKs and the main Prometheus clients already emit exemplars on histograms.
Span metrics: metrics generated from traces
Another way to guarantee correlation is to generate RED metrics from the spans themselves. The Collector’s spanmetrics connector does exactly that:
connectors:
spanmetrics:
histogram:
explicit:
buckets: [50ms, 100ms, 250ms, 500ms, 1s, 2s, 5s]
dimensions:
- name: http.request.method
- name: http.response.status_code
service:
pipelines:
traces:
receivers: [otlp]
exporters: [spanmetrics, otlphttp/backend]
metrics/spanmetrics:
receivers: [spanmetrics]
exporters: [otlphttp/backend]
The metrics are born with the same attributes as the traces, which makes it easy to navigate from one to the other. Note: these metrics must be computed before any trace sampling; otherwise, the rates would be wrong.
Continuous profiling: the fourth signal
Traces show where time was spent across services. But when the slow span is “process order” and it doesn’t call anything external, the question becomes: which function inside the process is consuming CPU or memory?
Continuous profiling collects stack samples all the time, with low overhead, and lets you compare behavior across times of day, versions, and instances. The result is usually visualized as a flame graph.
Why eBPF changed the game
With eBPF, the profiler runs in the kernel and samples the stacks of every process on the node, without changing code or restarting applications. Examples:
- Parca Agent and Grafana Alloy (eBPF profiling component, sending to Pyroscope);
- The eBPF profiler donated to the OpenTelemetry project, the foundation of OTel’s profiling signal, still in development.
eBPF also powers zero-code auto-instrumentation: Grafana Beyla, also donated to OpenTelemetry, generates metrics and traces for HTTP and gRPC requests by observing traffic in the kernel. That’s useful for legacy services nobody wants to (or can) instrument.
For languages with a managed runtime (JVM, .NET, Python, Node.js), symbol quality varies; in some cases, a language-specific profiler (via the SDK) gives more accurate results and lets you link the profile to each span (span profiles).
A complete investigation flow
Alert: the checkout error budget burn rate spiked (see symptom-based alerting).
- Metrics (RED): the dashboard shows the p99 of the
POST /ordersendpoint climbing from 400 ms to 3 s since 9:05 PM. - Exemplar: clicking a dot on the chart opens a 3.2 s trace.
- Trace: 2.8 s is in the
calculate_shippingspan, inside checkout itself, with no external calls. - Trace logs: no errors, but one warning: “shipping table reloaded” on every request.
- Profiling: the checkout flame graph, compared with the previous day, shows 60% of CPU in JSON deserialization inside
load_shipping_table. - Cause: the 9 PM deploy accidentally disabled the shipping table cache.
From alert to line of code, without guessing and without depending on whoever knows the system. That’s how correlation reduces MTTR.
Caveats
- Cost: continuous profiling and full traces generate volume. Use telemetry pipelines to sample and filter.
- Synchronized clocks (NTP) across nodes: time-window correlation depends on it.
- Sensitive data: logs and span attributes should not carry personal data.
- eBPF permissions: eBPF agents need elevated privileges on the node; treat them as security-critical components.
Checklist
- Identical resource attributes across all signals
- Structured logs with
trace_idandspan_id - Exemplars enabled and visible on latency dashboards
- RED metrics generated from or linked to traces
- Continuous profiling on critical services
- One-click navigation between signals in the visualization tool
Real observability means being able to ask a new question during an incident, and follow the answer from one signal to the next without losing the thread.