AWS 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 SDK and the ADOT Collector components. 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.

The ADOT Lambda Layers supports the following types of confmap providers: file, env, yaml, http, https and s3. To customize the ADOT collector configuration using different Confmap providers, Please refer to Confmap providers section for more information.

Once your collector configuration is set through a confmap providers. Create an environment variable on your Lambda function OPENTELEMETRY_COLLECTOR_CONFIG_FILE and set the path of configuration w.r.t to the confmap provider as its value. for e.g, if you are using a file configmap provider, set its value to /var/task/*<path/<to>/<filename>*. This will tell the extension where to find the collector configuration.

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

#collector.yaml in the root directory
#Set an environment variable 'OPENTELEMETRY_COLLECTOR_CONFIG_FILE' to '/var/task/collector.yaml'
receivers:
otlp:
protocols:
grpc:
endpoint: "localhost:4317"
http:
endpoint: "localhost:4318"
exporters:
logging:
awsxray:
service:
pipelines:
traces:
receivers: [otlp]
exporters: [awsxray]
metrics:
receivers: [otlp]
exporters: [logging]
telemetry:
metrics:
address: localhost:8888

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}

You can configure environment variables via CloudFormation template as well:

Function:
Type: AWS::Serverless::Function
Properties:
...
Environment:
Variables:
OPENTELEMETRY_COLLECTOR_CONFIG_FILE: /var/task/collector.yaml

Also, to load configuration from an S3 object

Function:
Type: AWS::Serverless::Function
Properties:
...
Environment:
Variables:
OPENTELEMETRY_COLLECTOR_CONFIG_FILE: s3://<bucket_name>.s3.<region>.amazonaws.com/collector_config.yaml

Loading configuration from S3 will require that the IAM role attached to your function includes read access to the relevant bucket.

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

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.