AWS Lambda
Send traces and logs to Last9 from AWS Lambda functions using OpenTelemetry
Use OpenTelemetry to instrument your AWS Lambda functions and send telemetry data to Last9. This integration uses the AWS Distro for OpenTelemetry (ADOT) Layer for automatic instrumentation with no code changes required.
Prerequisites
- Last9 cluster created
- Obtain your OTLP endpoint and auth header: Last9 OpenTelemetry Integration
- AWS Lambda function deployed
- Access to AWS Console or AWS CLI
Add ADOT Layer to Lambda
Find the layer ARN
Get the latest ADOT layer ARN for your AWS region and runtime from the AWS ADOT Lambda documentation.
Example ARNs for ap-south-1 (Mumbai):
# Node.jsarn:aws:lambda:ap-south-1:615299751070:layer:AWSOpenTelemetryDistroJs:9
# Pythonarn:aws:lambda:ap-south-1:615299751070:layer:AWSOpenTelemetryDistro:5
# Javaarn:aws:lambda:ap-south-1:615299751070:layer:AWSOpenTelemetryDistroJava:7Add the ADOT Layer to Lambda
- Open your Lambda function in the AWS Console
- Scroll to the Layers section
- Click Add a layer
- Select Specify an ARN
- Paste the ADOT layer ARN for your region and runtime
- Click Add
Configure Environment Variables
Set Required Environment Variables
Add the following environment variables to your Lambda function configuration:
-
Go to Configuration → Environment variables
-
Click Edit and add these variables:
AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-instrumentOTEL_SERVICE_NAME=<your-service-name>OTEL_EXPORTER_OTLP_ENDPOINT=$last9_otlp_endpointOTEL_EXPORTER_OTLP_HEADERS=authorization=$last9_basic_auth_headerOTEL_EXPORTER_OTLP_PROTOCOL=http/protobufOTEL_TRACES_EXPORTER=otlpOTEL_TRACES_SAMPLER=always_onOTEL_PROPAGATORS=tracecontext,baggageOTEL_RESOURCE_ATTRIBUTES=deployment.environment=productionImportant notes:
- Replace
<your-service-name>with a descriptive name (e.g.,payment-lambda,user-service) - Use lowercase
authorizationin the headers configuration - Replace
$last9_otlp_endpointand$last9_basic_auth_headerwith values from your Last9 integration settings
- Replace
Verification
Test Your Lambda Function
Invoke your Lambda function from the AWS Console or using the AWS CLI:
aws lambda invoke \ --function-name your-function-name \ --payload '{"test": "event"}' \ response.jsonView Traces in Last9
- Log in to your Last9 dashboard
- Navigate to the Traces section
- Filter by your service name
- Traces should appear within 1-2 minutes of invocation
Troubleshooting
If traces are not appearing:
-
Enable debug logging:
OTEL_LOG_LEVEL=debug -
Verify the ADOT layer is attached to your Lambda function
-
Check CloudWatch Logs for error messages or initialization failures
-
Verify environment variables are set correctly with no extra quotes
-
Test the sampler is enabled by setting
OTEL_TRACES_SAMPLER=always_on
If you see “Recording is off, propagating context in a non-recording span”, ensure OTEL_TRACES_SAMPLER=always_on is set.
For additional support, reach out to Last9 support at support@last9.io.