-
Notifications
You must be signed in to change notification settings - Fork 837
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(opentelemetry-instrumentation-http, opentelemetry-instrumentation-grpc): generate esm build files too #5351
base: main
Are you sure you want to change the base?
Conversation
06acb2b
to
077947d
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5351 +/- ##
=======================================
Coverage 94.58% 94.58%
=======================================
Files 318 318
Lines 8069 8069
Branches 1701 1701
=======================================
Hits 7632 7632
Misses 437 437 |
…n-grpc): generate esm build files too
077947d
to
00079b3
Compare
Hi, thank you for your contribution. 🙂 A few (naive) questions:
|
Hi @pichlermarc
I am not sure, for which case
Yes, as you said, there are not many things in those modules to be tree-shaken out, but the real motivation to bundle these modules as ESM modules too is having proper tree-shaking for their transitive dependencies. As one example, these modules (
I have tested to check whether instrumentation works when bundled with cc @dyladan |
That must be the reason then. If it imports
Ah, I see. I did not think of the transitive ones earlier. I can see CJS introducing a bunch of overhead in that case.
What I'm mainly concerned about is usage outside of Lambda. The way we export ESM, the ESM entrypoints are used by bundlers like As a long-term solution, and if we want to make changes like this for more packages in this repo (the same applies to contrib), then I personally see #4744 as a prerequisite. I think adding more ESM entrypoints on a large scale without proper tests in place will cost us a lot of time down the line. IMO bundler tests and some kind of automated bundle-size tests are what really hold us back in making meaningful changes in improving bundler support and bundle size. For now I will accept this PR if proof of manual testing is provided (for instance via another repo that links to locally built packages, or branch on a fork of this repo where the manual test package is added in If the plan is to do this for more than these two instrumentation then my recommendation would be to consider working on #4744 first, then adding some sort of automated bundle-size reporting. Doing that will make it immediately clear to reviewers that PRs that are opened:
With these two things in place we can improve quicker (shorter review cycle due to automated tests/reporting) on a larger scale (more packages) and it will help us maintain support long-term. A side note: while I'm stating that this would speed up things, we're currently working on SDK 2.0 as our main focus, reviews may be slow during that time since this does not fall into our focus at the moment. We have identified bundle size improvements as a possible future focus topic. We may pick it if we're done with one of the current focus topics, at which point there will be less friction in getting changes like this in. (Ref #5149) |
@pichlermarc Got it. @dyladan had mentioned some issues about the current approach and I just wanted to follow the same approach. So when the new approach is implemented, all the implementations of the current approach can be migrated all together to the new approach. |
@pichlermarc BTW, I have also been thinking of sending another PR to js-contrib repo for the rest of the instrumentation packages :) |
@pichlermarc and I am also aware of |
Which problem is this PR solving?
As OTEL FAAS SIG, we are working on reducing OTEL Lambda Nodejs layer coldstart overhead and bundling has the biggest impact. But bundling tools like webpack, esbuild don't like CJS modules while tree-shaking, but ESM modules. So, in this PR, we are configuring build process to generate ESM build files for the
opentelemetry-instrumentation-http
andopentelemetry-instrumentation-grpc
modules.Short description of the changes
To be able to generate ESM build files for
opentelemetry-instrumentation-http
andopentelemetry-instrumentation-grpc
modules too, this PRtsconfig.esm.json
andtsconfig.esnext.json
filespackage.json
package.json
for their discoverabilityType of change
Please delete options that are not relevant.
How Has This Been Tested?
It is observed that ESM builds are generated under
/build/esm
folder for theopentelemetry-instrumentation-http
andopentelemetry-instrumentation-grpc
modules.Checklist: