Implement log-trace correlation by injecting trace_id into structured logs using the OTel logs bridge

domain: opentelemetry.io · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Use the OTel logs bridge API to connect your existing logging library (such as zap, logrus, or log4j) to the OTel SDK
  2. Ensure the logging bridge reads the active span context and appends trace_id and span_id fields to each log record
  3. Export logs via OTLP to a backend that supports log-trace correlation, such as Grafana Loki with Tempo or Datadog
  4. In the backend, configure the correlation link so clicking a trace_id in a log record navigates to the trace view
  5. Validate correlation by generating a request, finding its log line, and confirming the trace_id resolves correctly

Known gotchas

Related routes

Bridge existing log framework output (Java Logback / Python logging) into OTel Logs using the OTel Logs Bridge API
opentelemetry.io · 5 steps · unrated
Correlate traces, metrics, and logs using OTel exemplars and trace context injection for a unified debugging workflow
opentelemetry.io · 5 steps · unrated
Configure Grafana Tempo to ingest OTLP traces, enable TraceQL metrics, and link Tempo to a Loki datasource for trace-to-log correlation
grafana.com · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans