In Node.js, there are plenty of ways to make an outgoing HTTP call. The built-in http module works, but it is hard to use. Libraries like axios make that easier. OpenTelemetry instrumentation adds spans and propagation to these, included in getNodeAutoInstrumentations().
There’s also a built-in fetch module, which works somewhat-but-not-entirely like the browser’s fetch function. However, it is not instrumented by OpenTelemetry! You’d think it is, because there’s an instrumentation-fetch package, but that only works for the browser. 😝
Until now! A few weeks ago, the instrumentation-undici package made it into opentelemetry-js-contrib. fetch is backed by undici, so this library makes the client spans and outgoing propagation work.
Soon it will be included in getNodeAutoInstrumentations(). Meanwhile, add it to your specified instrumentations. (code example)
const sdk = new NodeSDK({
traceExporter,
instrumentations:
[getNodeAutoInstrumentations(),
new UndiciInstrumentation()]
});






