-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
test(e2e): Add e2e test for AWS lambda in ESM mode #12833
Conversation
@@ -23,7 +23,8 @@ | |||
"esbuild": "0.20.0", | |||
"glob": "8.0.3", | |||
"ts-node": "10.9.1", | |||
"yaml": "2.2.2" | |||
"yaml": "2.2.2", | |||
"rimraf": "^5.0.0" |
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.
not sure why but without adding rimraf explicitly here, I can't use the yarn test:run
command to run e2e tests locally as rimraf isn't found otherwise 🤔
5b962b7
to
8d1fa8f
Compare
|
||
const handler = Sentry.wrapHandler(async () => { | ||
await new Promise(resolve => { | ||
const req = http.request( |
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.
took me ages to find out why the previously used http.get
call didn't produce a span. Turns out it's an Otel ESM bug. Reported it to Otel here: open-telemetry/opentelemetry-js#4857
Anyway, this http.request
call now emits a span which we assert on in the test. So this shows that otel instrumentation generally works
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.
nice find
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.
really nice to have an e2e test for this!
{ | ||
/* Run your local dev server before starting the tests */ | ||
webServer: [ | ||
{ | ||
command: `node start-event-proxy.mjs && pnpm wait-port ${eventProxyPort}`, | ||
port: eventProxyPort, | ||
stdout: 'pipe', | ||
}, | ||
], | ||
}, | ||
); |
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.
l: Is this needed? The base config is already doing this ootb.
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.
Right now, it somewhat is necessary because the shared playwright config always expects an additional startCommand
to start an application/development server. For our AWS Lambda tests, we don't need this because we invoke the function from within the test file. I'll open a separate PR to make startCommand
optional since this concerns all e2e tests relying on the shared config.
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.
Ah, understood. Thanks for the explanation!
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.
PR to refactor: #12842
This PR adds an E2E test app that simulates running an AWS lambda function in ESM mode. At the same time, this test app represents the state of how to manually use the
@sentry/aws-serverless
SDK for ESM-based lambda functions. For the moment, the plan is to document this as follows:@sentry/aws-serverless
with the package manager of your choiceNODE_OPTIONS: '--import @sentry/aws-serverless/awslambda-auto
SENTRY_DSN: '<your-dsn>'
SENTRY_TRACES_SAMPLE_RATE: '1.0'
Sentry.wrapHandler
node_modules
directory is deployed alongside your lambda codeUnfortunately, we can't get around highest friction points:
Sentry.wrapHandler
wrappernode_modules
are deployed alongside lambda codeThis, we'll only get rid off with an ESM lambda layer, and possibly not at all for the
Sentry.wrapHandler
part.ref #12409