If you are specifying the elastic-apm-node/start module via the NODE_OPTIONS environment variable, as described at Monitoring AWS Lambda Node.js Functions | APM Node.js Agent Reference [4.x] | Elasticand have the arn:aws:lambda:<REGION>:267093732750:layer:elastic-apm-node-ver-4-1-0:1 lambda layer install, then I would expect that to work.
My best first guess is that you may not have the layer installed.
Some notes/warnings:
I haven't tested this with a webpack-bundled Lambda function myself.
You explicitly do not want the "elastic-apm-node" package listed in your dependencies and bundled with webpack. For the Lambda case, the elastic-apm-node should come from the Lambda layer. Having a second elastic-apm-node bundled into the bundle will confuse things.
If you are unable to get it working, are you able to show me a small reproduction git repo with a trivial Lambda function module that is bundled with webpack as you are using it? I could then try to run it myself in Lambda to see if I can reproduce.
Well its definitely installed we are using serverless and i can see post deployment of the function that layer is available for the function. And i can see the environment variable present as NODE_OPTIONS: -r elastic-apm-node/start
I did try in my initial attempt to not specify elastic-apm-node . But then included it based on the logs. I have removed it but cant seem to get this error sorted.
Sorry I am kind of confused on this point
elastic-apm-node cannot work inside a bundle
we do use webpack to bundle the Lambdas we have Mono Repo based repository ? Can i specify the package in web-pack externals and get it working we do specify aws-sdk in the externals for example?
We are also using telemetry logs extension based layer that extracts logs and sends it to ELK stack. Wondering if that can be an issue ?
Using webpack's "externals" config should work, yes.
Are you able to put together a small reproduction case that I could try to play with? That would likely be the fastest way for me to try to find the issue.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.