ObserveNow
...
Cloud Providers
Amazon Web Services (AWS)

AWS Lambda Functions

Overview

This document outlines the process of automatically instrumenting AWS Lambda functions using OpenTelemetry (OTel) layers. It details the necessary steps for adding Lambda layers, configuring environment variables, and integrating the OpenTelemetry Collector for effective observability.

This integration works for Metrics and Traces. Since OpenTelemetry Logs support is unstable for most languages, we recommend using the Cloudwatch exporter for bringing AWS Lambda logs into ObserveNow

Supported Languages

OpenTelemetry provides auto-instrumentation support for the following AWS Lambda runtimes: Java, JavaScript, Python, Ruby

Steps for Instrumentation

Step 1: Add the OTel Collector Lambda Layer

Before instrumenting your application, you must add the OpenTelemetry Collector Lambda layer. Follow these steps:

  1. Navigate to the Lambda function you intend to instrument
  2. In the Layers section of the Designer, click Add a layer
  3. Under Specify an ARN, enter the ARN for the OTel Collector Lambda layer, ensuring to replace <region> with the appropriate AWS region for your Lambda function.Find the most recent Collector layer release here
  4. Make sure to use the layer in the same region as your Lambda functions. The community publishes layers in all available regions. Example: arn:aws:lambda:<region>:184161586896:layer:opentelemetry-collector-amd64-0_11_0:1

Note: Ensure that the layers are deployed in the same AWS region as your Lambda function, as Lambda layers are region-specific resources.

Step 2:Add the Instrumentation Lambda Layer

Add the instrumentation layer corresponding to your selected programming language by following the same steps as above:

  • For Python example: arn:aws:lambda::184161586896:layer:opentelemetry-python-0_10_0:1
  • Find the most recent instrumentation layer release for your language and use it’s ARN after changing the <region> tag to the region your Lambda

Note: Ensure that the layers are deployed in the same AWS region as your Lambda function, as Lambda layers are region-specific resources.

Step 3: Configure Environment Variables

  • Adjust the entry point of your application by configuring the AWS_LAMBDA_EXEC_WRAPPER environment variable according to your programming language.
    • For Node.js, Java, or Ruby: AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-handler
    • For Python: AWS_LAMBDA_EXEC_WRAPPER=/opt/otel-instrument
  • Create an environment variable to specify the configuration file for the OpenTelemetry Collector: OPENTELEMETRY_COLLECTOR_CONFIG_FILE=/var/task/collector.yaml

Step 4: Configure the OpenTelemetry Collector

The configuration of the OTel Collector Lambda layer follows the OpenTelemetry standard.

By default, the OTel Collector Lambda layer uses the config.yaml. Since we want to use a customization, create a collector.yaml file in the root directory

YAML


Step 5: View the metrics in ObserveNow

Metrics collected from Lamda function can be viewed under the Explore section of ObserveNow Grafana

Document image


Step 6: View the traces in ObserveNow

Traces collected from Lamda function can be viewed under the Explore section of ObserveNowGrafana

Document image