Skip to content
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(nodejs): bundling with webpack #1679

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

serkan-ozal
Copy link
Contributor

@serkan-ozal serkan-ozal commented Jan 25, 2025

With this PR, core (wrapper.js and most) of the OTEL AWS Lambda Node.js layer is bundled (tree-shaken and minified) with Webpack. So, this significantly reduces AWS Lambda coldstart delay of the OTEL AWS Lambda Node.js layer.

Additionally, with this PR, users can also disable metrics and logs by OTEL_METRICS_EXPORTER=none and OTEL_LOGS_EXPORTER=none to cut some more (~30 ms) coldstart delay if they don't need metrics and logs, but just traces.

  • ✅ All tests are passing
  • ✅ Tested with CJS and ESM based Lambda handlers

According to my experiments,

  • the coldstart delay reduces to ~220 ms from ~550 ms: 60% coldstart reduction (190 ms if metrics and logs are disabled as described above)
  • the Lambda layer artifact size reduces to 471 KB from 8.9 MB: 95% package size reduction

There are still improvements we can do over this:

  • There are improvements have been merged into the opentelemetr-js and opentelemetry-js-contrib repositories, but have not released and used in the Lambda layer yet.
  • There are still pending improvement PRs to the opentelemetr-js and opentelemetry-js-contrib repositories waiting for review.
  • Cache compiled V8 bytecode of the core (wrapper.js) and reuse it without compiling during coldstart.

Hopefully, with all these improvements, OTEL AWS Lambda Node.js layer coldstart overhead will be down to two digit ms (< 100 ms).

Besides that, we also need some improvements in the OTEL Lambda collector extension as it adds additional 270-280 ms delay to the coldstart.

@serkan-ozal serkan-ozal force-pushed the feat/nodejs/bundling-with-webpack branch from d5ff80c to d3d5182 Compare January 25, 2025 10:21
@serkan-ozal serkan-ozal force-pushed the feat/nodejs/bundling-with-webpack branch from d3d5182 to 3c93842 Compare January 25, 2025 10:26
@serkan-ozal serkan-ozal marked this pull request as ready for review January 25, 2025 10:30
@serkan-ozal serkan-ozal requested a review from a team as a code owner January 25, 2025 10:30
@tylerbenson
Copy link
Member

@pragmaticivan @martinkuba would you mind taking a look at this please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants