Skip to content
Last9 named a Gartner Cool Vendor in AI for SRE Observability for 2025! Read more →
Last9

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.js
arn:aws:lambda:ap-south-1:615299751070:layer:AWSOpenTelemetryDistroJs:9
# Python
arn:aws:lambda:ap-south-1:615299751070:layer:AWSOpenTelemetryDistro:5
# Java
arn:aws:lambda:ap-south-1:615299751070:layer:AWSOpenTelemetryDistroJava:7

Add the ADOT Layer to Lambda

  1. Open your Lambda function in the AWS Console
  2. Scroll to the Layers section
  3. Click Add a layer
  4. Select Specify an ARN
  5. Paste the ADOT layer ARN for your region and runtime
  6. Click Add

Configure Environment Variables

Set Required Environment Variables

Add the following environment variables to your Lambda function configuration:

  1. Go to ConfigurationEnvironment variables

  2. Click Edit and add these variables:

    AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-instrument
    OTEL_SERVICE_NAME=<your-service-name>
    OTEL_EXPORTER_OTLP_ENDPOINT=$last9_otlp_endpoint
    OTEL_EXPORTER_OTLP_HEADERS=authorization=$last9_basic_auth_header
    OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
    OTEL_TRACES_EXPORTER=otlp
    OTEL_TRACES_SAMPLER=always_on
    OTEL_PROPAGATORS=tracecontext,baggage
    OTEL_RESOURCE_ATTRIBUTES=deployment.environment=production

    Important notes:

    • Replace <your-service-name> with a descriptive name (e.g., payment-lambda, user-service)
    • Use lowercase authorization in the headers configuration
    • Replace $last9_otlp_endpoint and $last9_basic_auth_header with values from your Last9 integration settings

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.json

View Traces in Last9

  1. Log in to your Last9 dashboard
  2. Navigate to the Traces section
  3. Filter by your service name
  4. Traces should appear within 1-2 minutes of invocation

Troubleshooting

If traces are not appearing:

  1. Enable debug logging:

    OTEL_LOG_LEVEL=debug
  2. Verify the ADOT layer is attached to your Lambda function

  3. Check CloudWatch Logs for error messages or initialization failures

  4. Verify environment variables are set correctly with no extra quotes

  5. 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.

Next Steps