1. Add the OpenTelemetry Lambda Layer
Find the latestlayer-nodejs ARN for your AWS region from the opentelemetry-lambda releases page. Add the layer ARN to your function.
2. Add the Collector Lambda Extension
Find the latestlayer-collector ARN for your AWS region from the opentelemetry-lambda releases page.
Add the layer ARN to your function and then add the following collector.yaml file to the root of your Lambda deployment folder. Replace YOUR_TRACE0_ENV_API_KEY with the API key from your Trace0 environment.
3. Set Environment Variables
Add the following environment variables to your Lambda function.4. Add Logger
To correlate logs with traces in Trace0, your application must use an OpenTelemetry-supported logger. We recommend using Pino, a low overhead JavaScript logger for Node.js. The instructions below usePino, but the same approach applies to other supported loggers such as Winston.
First, install the library:
logger.js file:
Setting
OTEL_NODE_ENABLED_INSTRUMENTATIONS disables all the default instrumentation libraries and only enables the ones you specify, except the AWS SDK v3 instrumentation, which is always loaded regardless. See here for full details on configuring the auto instrumentation for Node.js Lambda.