Layer for running NodeJS applications on AWS Lambda with OpenTelemetry. Adding the layer and pointing to it with
the AWS_LAMBDA_EXEC_WRAPPER environment variable will initialize OpenTelemetry, enabling tracing with no code change.
To use, add the layer to your function configuration and then set AWS_LAMBDA_EXEC_WRAPPER to /opt/otel-handler.
AWS SDK v3 instrumentation is included and loaded automatically by default. A subset of instrumentations from the OTEL auto-instrumentations-node metapackage are also included.
Following instrumentations from the metapackage are included:
amqplibbunyancassandra-driverconnectdataloaderdns- defaultexpress- defaultfsgraphql- defaultgrpc- defaulthapi- defaulthttp- defaultioredis- defaultkafkajsknexkoa- defaultmemcachedmongodb- defaultmongoosemysql- defaultmysql2nestjs-corenet- defaultpg- defaultpinoredis- defaultrestifysocket.ioundiciwinston
Instrumentations annotated with "- default" are loaded by default.
To only load specific instrumentations, specify the OTEL_NODE_ENABLED_INSTRUMENTATIONS environment variable in the lambda configuration.
This disables all the defaults, and only enables the ones you specify. Selectively disabling instrumentations from the defaults is also possible with the OTEL_NODE_DISABLED_INSTRUMENTATIONS environment variable.
The environment variables should be set to a comma-separated list of the instrumentation package names without the
@opentelemetry/instrumentation- prefix.
For example, to enable only @opentelemetry/instrumentation-http and @opentelemetry/instrumentation-undici:
OTEL_NODE_ENABLED_INSTRUMENTATIONS="http,undici"To disable only @opentelemetry/instrumentation-net:
OTEL_NODE_DISABLED_INSTRUMENTATIONS="net"To build the layer and sample applications in this nodejs folder:
First install dependencies:
npm install
Then build the project:
npm run build
You'll find the generated layer zip file at ./packages/layer/build/layer.zip.
Sample applications are provided to show usage of the above layer.
- Application using AWS SDK - shows using the wrapper with an application using AWS SDK without code change.
- [WIP] Using OTel Public Layer