Skip to main content
Sumo Logic

AWS Lambda - NodeJS function instrumentation with Sumo Logic tracing

This document covers how to install and configure OpenTelemetry distributed tracing for AWS Lambda functions based on NodeJS and send the data to Sumo Logic.

To obtain tracing data from AWS Lambda functions developed in Node.js you can use OpenTelemetry NodeJS instrumentation. It provides auto instrumentation.

Requirements

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

  • NodeJS v12.x or newer
  • Lambda layers add permissions
  • HTTP Traces Source endpoint URL

Sumo Logic AWS Distro Lambda Layer supports:

  • nodejs12.x and nodejs14.x runtimes
  • x86_64 architecture

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.

  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.
    clipboard_ef1661f179cf04b7491d8f5145a752a4d.png

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

    clipboard_e4a3c5aa553edc9132da5d62e6f80f3e6.png

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

    • AWS_LAMBDA_EXEC_WRAPPER = /opt/otel-handler enables auto-instrumentation.

    • OTEL_TRACES_SAMPLER = always_on - enables traces sampling.

    • OTEL_SERVICE_NAME = YOUR_SERVICE_NAME - 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.

    • Tracing application  is set with the OTEL_RESOURCE_ATTRIBUTES environment variable.

      • application=YOUR_APPLICATION_NAME - the string value, if the function is a part of complex system/application then set it for all other functions/applications.

        Additional attributes are comma separated key/value pairs (this is also a way to add additional information to the spans, just after comma add additional key=value pair) such as, OTEL_RESOURCE_ATTRIBUTES=application=YOUR_APPLICATION_NAME,key1=value1

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

    clipboard_e4a3fceb5b79f1c70e086e4e9e2563984.png

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

Context propagation

In case of external request to the Lambda function, it is important to propagate the context. Enabling AWS X-Ray context propagation on the client side will help to visualize the complex flow of the trace. For applications instrumented by OpenTelemetry SDK it is enough to install AWS X-Ray propagator dependency specific for an instrumentation and configure OTEL_PROPAGATORS environment variable (for example: export OTEL_PROPAGATORS=tracecontext,baggage,xray).

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