-
Notifications
You must be signed in to change notification settings - Fork 233
Description
In order to detect when certain methods are called and provide timings for those method calls, the Node.js Agent uses a module named require-in-the-middle. This module "hooks" (monkey-patches, intercepts, etc.) the initial loading of Node.js CommonJS module and allows us to wrap the methods we want with our custom timing and span generation.
Node 15 (and it's LTS support partner, Node 16) mark the support of ECMAScript modules (also known as ES6 modules) as non-experimental. https://nodejs.org/docs/latest-v15.x/api/esm.html#esm_modules_ecmascript_modules
This means third part code can begin using ECMAScript modules (import
) in place of CommonJS modules (require
). The require-in-the-middle
module does not hook these new import
/ECMAScript modules. This means any normally instrumented module that uses ECMAScript
modules will not be instrumented by the Node.js Agent.
We need to determine the best was to hook these new modules. (perhaps the experimental loaders, perhaps compilation/transpilation, perhaps something else).
This will be a long term effort. If folks have ideas on approaches we'd love to hear about them.
Work Around: In the meantime, users can fallback to importing modules via require
. If there's an instrumented module that's providing ECMAScript only modules, or the agent is somehow not working with the new ECMAScript features, we'd like to hear about them.
Todo: