Skip to content

Create ESM Lambda Layer #12856

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

Open
10 tasks
Lms24 opened this issue Jul 10, 2024 · 10 comments
Open
10 tasks

Create ESM Lambda Layer #12856

Lms24 opened this issue Jul 10, 2024 · 10 comments

Comments

@Lms24
Copy link
Member

Lms24 commented Jul 10, 2024

(extracted from #12409)

Since using the Sentry AWS Serverless SDK is far from easy in ESM-based Lambda functions, we should look into creating a layer for ESM or making our current layer compatible with both, CJS and ESM.

I outlined some of the prior investigation to this in #12322 and #12409.

One major blocker for a code-less Sentry SDK usage like in CJS is that our tryPatchHandler function we use to auto-wrap CJS lambda functions can't be applied to ESM Lambda functions (it uses require 😢). However, we can create a layer and tell people to manually init the SDK in code. Having the layer is still a huge improvement because users don't have to deploy their node_modules like when installing the SDK via NPM. h/t @andreiborza for pointing this out today!

ESM Layer v0 (no auto-wrapping)

  • Create ESM layer that provides the SDK dependencies
  • Document how to use layer with code changes
  • Add flag in event payload indicating if event was sent from lambda layer or from NPM-installed pacakge

ESM layer v1 (auto-wrapping)

  • Investigate why AWS Lambda Otel instrumentation doesn't work in ESM (+ possibly fix it)
  • Find way to auto-wrap handler to permit code-less SDK setup
  • Document code-less SDK setup via environment variables

Stretch Goals

@Lms24
Copy link
Member Author

Lms24 commented Jul 10, 2024

Extracted this issue so we can link to it from docs that mention the ESM limitations around the layer

@paolostyle
Copy link

Is there any progress on this? Also I'd suggest implementing the integration using AWS Lambda Extensions, the issues mentioned in #3051 are very much present currently, Sentry adds a lot of overhead and it sounds like the Lambda Extensions is the solution to that.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Sep 3, 2024
@Lms24
Copy link
Member Author

Lms24 commented Sep 3, 2024

Hi, no progress on this at the moment, as we're busy with a lot of other issues.

I'm gonna tag @andreiborza if you get some time or need a break from Solid(Start). I gotta admit I had no idea that #3051 was receiving replies (this issue predates almost everyone working on the team by now). The unfortunate thing is that this is a hard problem to solve.

IIRC there are some limitations to the Lambda Extension API why we can't use it but I'll ask around a bit.

@microadam
Copy link

@Lms24 would love to hear any issues you are aware of with the Lamba Extensions API, as having implemented this: #3051 (comment)

We are able to use sentry without the noticeable delay on a fairly high traffic system. Its probably far from perfect (better batching could be introduced for example and currently the data is sent on the NEXT lambda invocation). Any details would be great :) (or just a link to where any discussion on this might be taking place now / in the future so I could follow along!)

@andreiborza
Copy link
Member

Thanks @microadam, we'll revisit extensions and see if they're a viable path forward when working on this.

@kpujjigit
Copy link

Hi All, I'd like to check in on this support on behalf of a customer, it would greatly simplify their instrumentation.

@andreiborza
Copy link
Member

We're discussing this internally today. Will know more then.

@apetta
Copy link

apetta commented Apr 23, 2025

It would be nice to set the 'environment' for Sentry via a node env as well, couldn't see anything related to this in the docs

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 23, 2025
@s1gr1d
Copy link
Member

s1gr1d commented Apr 24, 2025

You are able to set it via an environment variable: https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#environment

Does this help you @apetta?

@apetta
Copy link

apetta commented Apr 24, 2025

You are able to set it via an environment variable: docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options#environment

Does this help you @apetta?

Ah, perfect! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

8 participants