Skip to main content
Sumo Logic

AWS Lambda - Python function instrumentation with Sumo Logic tracing

Welcome to the Sumo Logic AWS Lambda tracing BETA program, we are happy to work with you as an early adopter and design partner. If you have any questions or need help, reach us at tracing-eap@sumologic.com.

This document covers how to install and configure OpenTelemetry distributed tracing for AWS Lambda functions written in Python and send data to Sumo Logic.

To obtain telemetry data from AWS Lambda functions developed in Python language you can use the AWS Distro for Opentelemetry Lambda (ADOT Lambda) layer. ADOT provides packed OpenTelemetry Python libraries which automatically instrument Lambda functions. The biggest advantage of installing AWS Distro for Opentelemetry as a layer is disabling/enabling instrumentation of the Lambda function without changing the code.

Requirements

It is very simple to instrument your AWS Python Lambda function using the Sumo Logic AWS Distro Lambda layer. You'll need the following:

  • Python 3.8
  • Lambda layers add permissions
  • HTTP Traces Source endpoint URL

Sumo Logic AWS Distro Lambda layer

  1. Navigate to functions in the AWS Lambda Console and open the function you want to instrument.

  2. Navigate to the Layers section and click Add a layer.

    add a layer in aws console.png

  3. In the Choose a layer menu, select Specify an ARN and paste the ARN ID for your Lambda function AWS Region. Reference the table at the end of this document for the ARN ID.
    choose a layer in aws console.png

  4. Ensure the AWS Distro layer is present in the Layers section:

    python layer varificaion.png

  5. Navigate to the Configuration > Environment variables section and set up the following three environment variables:

    • AWS_LAMBDA_EXEC_WRAPPER = /opt/python/otel-instrument enables auto-instrumentation.

    • Tracing service name and application are set via OTEL_RESOURCE_ATTRIBUTES = service.name=YOUR_SERVICE_NAME,application=YOUR_APPLICATION_NAME. They are comma-separated key/value pair attributes (this is also a way to add additional information to the spans, just after comma add additional key=value pair). Ensure you define it as a string value that represents the function name and its business logic such as "Check SQS Lambda". This will appear as the tracing service name in Sumo Logic.

    • SUMOLOGIC_HTTP_TRACES_ENDPOINT_URL has to be set to send all gathered telemetry data to Sumo Logic. The URL comes from an HTTP Traces Endpoint URL. You can use an existing Source or create a new one if needed.

      4 environment variables in AWS console.png

  6. Your function should be successfully instrumented. Invoke the function and find your traces in the Sumo Logic Tracing screen.

Sumo Logic AWS Distro Lambda layers for AWS Region

Click to go back to Step 3.

AWS Region ARN
US East (N.Virginia) us-east-1 arn:aws:lambda:us-east-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
US East (Ohio) us-east-2 arn:aws:lambda:us-east-2:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
US West (N.Carolina) us-west-1 arn:aws:lambda:us-west-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
US West (Oregon) us-west-2 arn:aws:lambda:us-west-2:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Africa (Cape Town) af-south-1 arn:aws:lambda:af-south-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Asia Pacific (Hong Kong) ap-east-1 arn:aws:lambda:ap-east-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Asia Pacific (Mumbai) ap-south-1 arn:aws:lambda:ap-south-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Asia Pacific (Osaka) ap-northeast-3 arn:aws:lambda:ap-northeast-3:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Asia Pacific (Seoul) ap-northeast-2 arn:aws:lambda:ap-northeast-2:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Asia Pacific (Singapore) ap-southeast-1 arn:aws:lambda:ap-southeast-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Asia Pacific (Sydney) ap-southeast-2 arn:aws:lambda:ap-southeast-2:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Asia Pacific (Tokyo) ap-northeast-1 arn:aws:lambda:ap-northeast-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Canada (Central) ca-central-1 arn:aws:lambda:ca-central-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Europe (Frankfurt) eu-central-1 arn:aws:lambda:eu-central-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Europe (Ireland) eu-west-1 arn:aws:lambda:eu-west-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Europe (London) eu-west-2 arn:aws:lambda:eu-west-2:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Europe (Milan) eu-south-1 arn:aws:lambda:eu-south-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Europe (Paris) eu-west-3 arn:aws:lambda:eu-west-3:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Europe (Stockholm) eu-north-1 arn:aws:lambda:eu-north-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
Middle East (Bahrain) me-south-1 arn:aws:lambda:me-south-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1
South America (Sao Paulo) sa-east-1 arn:aws:lambda:sa-east-1:663229565520:layer:sumologic-aws-distro-otel-col-python38-lambda-layer:1