-
Notifications
You must be signed in to change notification settings - Fork 811
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
feat: ESM support for instrumentation #3698
Conversation
also, `this` doesnt work outside scope with esm
iitm added to ritm singleton tests stubbed to keep current behavior Co-authored-by: Purvi Kanal <kanal.purvi@gmail.com>
doesn't currently work with iitm register
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3698 +/- ##
==========================================
+ Coverage 93.19% 93.22% +0.02%
==========================================
Files 298 293 -5
Lines 9057 8883 -174
Branches 1864 1825 -39
==========================================
- Hits 8441 8281 -160
+ Misses 616 602 -14
|
Thank you for working on this! :) |
@JamieDanielson my personal superheroine!!! |
omg, wahoo, y'all got it over the line @JamieDanielson and @pkanal!!! |
That's very kind but I definitely cannot take all this credit. It's taken a lot of work from a lot of people, and this latest iteration has a ton of work done by my colleague Purvi (@pkanal) - it just only allows one name on the PR in GH 😃 |
experimental/packages/opentelemetry-instrumentation-http/src/http.ts
Outdated
Show resolved
Hide resolved
experimental/packages/opentelemetry-instrumentation/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts
Show resolved
Hide resolved
experimental/packages/opentelemetry-instrumentation/test/node/EsmInstrumentation.test.mjs
Outdated
Show resolved
Hide resolved
I'll also re-link the comment that Qard made over my PR #2846 (comment) which is still relevant to this one |
- pins versions in example app - node 20 support disclaimer - re-export hook.mjs file functions 😍
I don't have the ability to rerun workflows but I think the current status check failures may be related to some service issues GitHub is having today, as I've had similar-looking fails on other workflows that resolved when rerunning. |
@JamieDanielson seems my PR created a conflict in readme. Please update the limitations accordingly because once this PR is merge one limitation is gone (besides for node 20) 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you for putting in all the work. 🙂
As this is quite a significant change, I'll wait for another approval before merging this.
As the ESM module loader from NodeJS is experimental, so is our support for it. Feel free to provide feedback or report issues about it. | ||
|
||
**Note**: ESM Instrumentation is not yet supported for Node 20. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the limitations section below which tells ECMA script modules (using
import) is not supported as of now
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this mean? How can one use ESM without import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means that the limitations section requires changes in this PR because it removes one of them.
Before this PR ESM/import
was not supported and only CJS/require
worked.
Th limitation with bundlers stays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, super, thanks for the clarification :) a panic mode was already about to arise :D
Co-authored-by: Purvi Kanal <purvikanal@honeycomb.io>
Which problem is this PR solving?
Updates / Closes #1946
Short description of the changes
ECMAScript Modules (ESM) have become the standard module system for Node.js, but CommonJS (CJS) is also still used widely, so we need a way to enable instrumentation for both module systems. This is built upon / supersedes the work of previous PRs and discussions (#2640, #2763, #2846) .
import-in-the-middle
(IITM) as another hook, to be used instead ofrequire-in-the-middle
(RITM) when the argument is passed to use the new hook--experimental-loader=@opentelemetry/instrumentation/hook.mjs
(alternative option includes the ability to use--experimental-loader=import-in-the-middle/hook.mjs
with an added dependency onimport-in-the-middle
)npm run test:esm
and as part ofnpm run test
esm-http-ts
built in TypeScript that compiles to ESM and shows http instrumentation workingprocess.version
to preventundefined
version for ESM.Type of change
How Has This Been Tested?
Checklist: