AWS Lambda
Monitor your Node.js Lambda function and send its data at the end of each invocation, without changing your handler.
Set up your function
Package @vigilon/node with your function, then set these environment variables on the function. NODE_OPTIONS starts Vigilon before your handler loads, so your handler code does not change:
NODE_OPTIONS="--import @vigilon/node/register"
VIGILON_API_KEY="[YOUR_API_KEY]"
VIGILON_ENVIRONMENT="production"
Vigilon detects the Lambda runtime on its own and sends each invocation's data before Lambda freezes the function, so nothing is lost between invocations. You do not need to call shutdown().
The service name defaults to your function's name. Lambda does not set NODE_ENV or a similar variable for you, so VIGILON_ENVIRONMENT is required here.
If your deployment package has no package.json, Vigilon cannot find a version. Set VIGILON_SERVICE_VERSION from your deploy pipeline, for example to the commit SHA.
Bundling with esbuild
If you bundle your function with esbuild or a similar bundler, keep @vigilon/node and its @opentelemetry/* dependencies external. A bundler copies those libraries into one file, which stops Vigilon from hooking into your framework and database libraries.
Most frameworks have an external-modules setting for this, for example SST nodejs.esbuild.external, or the serverless-esbuild external option.