-
-
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
AWS lambda using layer not sending errors to Sentry #13663
Comments
Hi @fdx-caio, thanks for writing in. Could you show some snippets of your lambda function? Also, please link to one of these transactions. |
This is how my lambda code looks like that I am having issues with. This being built using esbuild to CommonJS
This example works as expected (Able to throw an error and see on Sentry)
Link to a event transaction on Sentry as requested |
@fdx-caio there's an error in the transpiled version, where's |
@andreiborza sorry that |
@fdx-caio ok, so the issue is basically with shimmer and esbuild. The exported handler cannot be redefined which is needed for us to wrap the handler with Sentry. See: evanw/esbuild#2199 (comment) Can you try writing your handler using If that doesn't help, I'm afraid you'll have to initialize Sentry in your handler and use |
@andreiborza Thanks for providing the esbuild context of the problem, I wasn't aware the exported handler couldn't be redefined. I was able to make it work by throwing an error and using the module.exports like you mentioned. However when I return a response error object to the lambda instead of throwing an error the Sentry integration layer is not being able to pick up the error, would you know if there is anything I can do to make the integration know it's an error? For context I am using ApiGateway and making my lambda handle a request and return a response to it Example of my error response provided to lambda
|
@fdx-caio you would probably have to manually check the statuscode and pass the response to |
@andreiborza it worked after following your suggestions, thanks for helping me sort out all my issues. We can close this issue as my integration is working now. |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/aws-serverless
SDK Version
arn:aws:lambda:ap-southeast-2:943013980633:layer:SentryNodeServerlessSDK:271
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
No response
Steps to Reproduce
I am integrating an serveless app with Sentry and encountered the following problem: I can't seem to find any errors thrown by my lambda in Sentry discovery or elsewhere, can confirm the lambda is throwing a bad request error but not appearing on Sentry. However other logs such as transactions does seem to appear.
For context I am not using the library wrapper or any dependency as I am expecting the layer to integrate and primarily emit any logs from my lambdas.
I have followed the setup strictly from this page and my app is running in CommonJS (CJS): https://docs.sentry.io/platforms/javascript/guides/aws-lambda/install/cjs-layer/
Layer: arn:aws:lambda:ap-southeast-2:943013980633:layer:SentryNodeServerlessSDK:271
Environment variables:
NODE_OPTIONS: "-r @sentry/aws-serverless/awslambda-auto"
SENTRY_DSN: "***"
SENTRY_TRACES_SAMPLE_RATE: "1.0"
SENTRY_ENVIRONMENT: "dev"
Expected Result
Expecting to see errors and other types of logs other than transaction on Sentry
Actual Result
Result showing transactions from Sentry
The text was updated successfully, but these errors were encountered: