-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core modules imported with require('node:...')
are not instrumented
#2816
Labels
Milestone
Comments
github-actions
bot
added
the
agent-nodejs
Make available for APM Agents project planning.
label
Jul 8, 2022
Aside: This hack results in working instrumentation: diff --git a/lib/instrumentation/index.js b/lib/instrumentation/index.js
index d2a5f587..e5e10035 100644
--- a/lib/instrumentation/index.js
+++ b/lib/instrumentation/index.js
@@ -43,7 +43,7 @@ var MODULES = [
'graphql',
'handlebars',
['hapi', '@hapi/hapi'],
- 'http',
+ ['http', 'node:http'],
'https',
'http2',
'ioredis', However, debug output from require-in-the-middle shows that (of course) it still doesn't recognize that
We should be sure that would have no surprises before considering this approach. So far the initial suggestion (fixing require-in-the-middle's concept of what is a "core" module) sounds more promising. |
1 task
sibelius
pushed a commit
to sibelius/apm-agent-nodejs
that referenced
this issue
Aug 30, 2022
…tic#2868) Starting in node v14.18.0, support for identifying core node modules with the 'node:'-prefix was added: https://nodejs.org/api/modules.html#core-modules Closes: elastic#2816
fpm-peter
pushed a commit
to fpm-git/apm-agent-nodejs
that referenced
this issue
Aug 20, 2024
…tic#2868) Starting in node v14.18.0, support for identifying core node modules with the 'node:'-prefix was added: https://nodejs.org/api/modules.html#core-modules Closes: elastic#2816
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instrumentation for the following does not work because
node:http
is required instead ofhttp
.Support for
node:
-prefixed imports to explicitly mean core modules was added in node v16.0.0 (and maybe in v14.8.0?). See nodejs/node#37246With require-in-the-middle debug logging:
The issue is that require-in-the-middle's
isCore
fails:We'll need to update require-in-the-middle to fix this. We should watch out for not separately wrapping
require('http')
andrequire('node:http')
, so perhaps a good answer would be to normalize thefilename
. E.g. a first naive stab could just drop the leadingnode:
if any. ... Yup, making this change in require-in-the-middle/index.js works:The text was updated successfully, but these errors were encountered: