AWS Open Distro for OpenTelemetry

AWS Distro for OpenTelemetry Lambda

AWS Distro for OpenTelemetry Lambda

The AWS Distro for OpenTelemetry now supports AWS Distro for OpenTelemetry Lambda layer. ADOT Lambda layers provides a plug-and-play user experience by automatically instrumenting a Lambda function, by packaging OpenTelemetry together with an out-of-the-box configuration for AWS Lambda and AWS X-Ray in an easy to setup layer. Users can enable and disable OpenTelemetry for their Lambda function without changing code.

Getting Started with AWS Lambda layers

Manual Steps for Private Lambda Layers

See the documentation on the OpenTelemetry Lambda repository.

Custom configuration for the ADOT Collector on Lambda

The ADOT Lambda layers combines both OpenTelemetry and the ADOT Collector. The configuration of the ADOT Collector follows the OpenTelemetry standard. By default, the ADOT Lambda layer uses config.yaml, which exports telemetry data to AWS X-Ray.

Please find the list of available components supported for custom configuration here. To enable debugging, you can use the configuration file to set log level to debug. See the example below.

To customize the collector configuration, add a configuration yaml file to your function code. Once the file has been deployed with a Lambda function, create an environment variable on your Lambda function OPENTELEMETRY_COLLECTOR_CONFIG_FILE and set it to /var/task/*<path/<to>/<filename>*. This will tell the extension where to find the collector configuration.

Here is a sample configuration file, collector.yaml in the root directory:

#collector.yaml in the root directory
#Set an environemnt variable 'OPENTELEMETRY_COLLECTOR_CONFIG_FILE' to '/var/task/collector.yaml'
loglevel: debug
#enables output for traces to xray
receivers: [otlp]
exporters: [logging, awsxray]

You can set this via the Lambda console, or via the AWS CLI.

aws lambda update-function-configuration --function-name Function --environment Variables={OPENTELEMETRY_COLLECTOR_CONFIG_FILE=/var/task/collector.yaml}

As an alternative to uploading your collector.yaml file directly with your code, you can zip your file and upload your zip as a separate Lambda layer. You can set this via the Lambda console, or via the AWS CLI.

aws lambda update-function-configuration --function-name Function --environment Variables={OPENTELEMETRY_COLLECTOR_CONFIG_FILE=/opt/collector.yaml}

You can configure environment variables via CloudFormation template as well:

Type: AWS::Serverless::Function

For more information about ADOT Collector configuration, such as adding ca/cert/key files, see the Github

Here is a blogpost which provides more context about the setup with an example for adding the AWS Distro for OpenTelemetry Lambda layer to the Lambda function.