Code QuizAdvanced

Correlating the Three Pillars

A request emits metrics, logs, and a trace, but the log can't be linked back to its trace.

Codejavascript
const { trace } = require('@opentelemetry/api');

function handleRequest(req, res) {
  const tracer = trace.getTracer('app');
  const span = tracer.startSpan('handleRequest');

  // Metric (one of the three pillars)
  requestCounter.add(1);

  // Log (one of the three pillars)
  console.log(JSON.stringify({
    level: 'info',
    message: 'Handling request',
    path: req.path
  }));

  span.end();
}

The three pillars (metrics, logs, traces) are all emitted, but observability engineers can't jump from a log line to its trace. What is the bug?