Description
(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
- Adapt Sentry integration to use ESM version of layer
- Document how to use Sentry integration for automatic adding of Sentry to (multiple) ESM lambda functions
- Look into Supporting SENTRY_DEBUG
- Look into the AWS Lambda Extensions API (@sentry/serverless adds ~300ms to function duration #3051 (comment))
Metadata
Metadata
Assignees
Type
Projects
Status