Skip to content

Create your own Lambda Layer in each OTel language using this starter code. Add the Lambda Layer to your Lamdba Function to get tracing with OpenTelemetry.

License

Notifications You must be signed in to change notification settings

oba11/opentelemetry-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenTelemetry AWS Lambda Extension

NOTE: This is an experimental AWS Lambda Extension for OpenTelemetry

The OpenTelemetry Lambda Extension provides a mechanism to export telemetry aynchronously from AWS Lambdas. It does this by embedding an OpenTelemetry Collector inside an AWS Extension Layer. This allows lambdas to use the OpenTelemetry Collector Exporter to send traces and metrics to any configured backend.

Installing

To install the OpenTelemetry Lambda Extension to an existing Lambda function using the aws CLI:

aws lambda update-function-configuration --function-name Function --layers arn:aws:lambda:<AWS REGION>:297975325230:layer:opentelemetry-lambda-extension:8

Alternatively, to configure the OpenTelemetry Lambda Extension via SAM, add the following configuration:

  Function:
    Type: AWS::Serverless::Function
    Properties:
      Layers:
        - arn:aws:lambda:<AWS REGION>:297975325230:layer:opentelemetry-lambda-extension:8
      ...
      Environment:
        Variables:
          OPENTELEMETRY_COLLECTOR_CONFIG_FILE: /var/task/collector.yaml

Configuration

The OpenTelemetry Collector uses yaml for configuration. To configure the collector, add a collector.yaml to your function and specifiy its location via the OPENTELEMETRY_COLLECTOR_CONFIG_FILE environment file.

Here is a sample configuration file:

receivers:
  otlp:
    protocols:
      grpc:
      http:
exporters:
  otlp:
    endpoint: destination:1234
    headers: {"header1":"value1"}
processors:
  batch:

service:
  extensions:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp]

Once the file has been deployed with a Lambda, configuring the OPENTELEMETRY_COLLECTOR_CONFIG_FILE will tell the OpenTelemetry extension where to find the collector configuration:

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

You can configure environment variables via yaml as well:

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

About

Create your own Lambda Layer in each OTel language using this starter code. Add the Lambda Layer to your Lamdba Function to get tracing with OpenTelemetry.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 59.3%
  • HCL 11.8%
  • Shell 7.2%
  • Python 6.8%
  • Java 4.9%
  • TypeScript 4.1%
  • Other 5.9%