Cannot send error to Elastic APM from AWS lambda

JasonREC
Thu, 30 Mar 2023 09:14:56 +0000
APM

Kibana version: Latest Cloud version

Elasticsearch version: Latest Cloud version

APM Server version: Latest Cloud version

APM Agent language and version:NodeJS

I followd exactly this page to do the set up (Monitoring AWS Lambda Node.js Functions | APM Node.js Agent Reference [3.x] | Elastic) setup for my app.

I use SAM tool to setup the template for cloudformation, everything is going well. Elastic APM connection is sucssful.

My app flow is simply a restful api, a request comes in then run some business logic and before I send back the response, I call a AWS SNS service since I need to run some extra background task, and the sns will send some payload to my another lambda function to proceed other api call. I used try catch block with axios there. if for example, api call failed such as token expire, error will pass to catch block, and inside catch block I simply have:

apm.setCustomContext(errorDetails)
apm.captureError(error)

errorDetails is my custom object

then after run the above 2 lines I just throw an error.

But when i check my cloud APM, I see the SNS tranaction, and it also record the api endpoint I call from my lambda, but there is no error showing at all even I call apm.captureError() since I deliberately make my token expired.

Could anyone help?

Thanks

4 posts - 3 participants