opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

Instrument modules loaded via `process.getBuiltinModule`?

Open timfish opened this issue 2 months ago • 0 comments

Node has added process.getBuiltinModule(id) to allow synchronous loading of built-in modules: https://github.com/nodejs/node/pull/52762

The idea is that library authors will now more easily be able to create cross runtime libraries that can conditionally load Node APIs only when running in Node:

if (globalThis.process?.getBuiltinModule) {
  // Running in Node.js, use the Node.js fs module.
  const fs = globalThis.process.getBuiltinModule('fs');
}

OpenTelemetry instruments modules via require-in-the-middle and import-in-the-middle but built-in modules loaded via this new API will not be instrumented as it doesn't go through require.

timfish avatar May 30 '24 10:05 timfish