Below we shall see the steps for AWS Python Serverless Auto-Instrumentation Monitoring in Atatus using OTel Lambda Layer.

  1. To incorporate the OpenTelemetry Lambda layer into your Python functions, include the following layers in your functions.

    arn:aws:lambda:<region>:184161586896:layer:opentelemetry-python-<version>
    arn:aws:lambda:<region>:184161586896:layer:opentelemetry-collector-<amd64|arm64>-<version>
    
    # example layer config
    
    # arn:aws:lambda:us-east-1:184161586896:layer:opentelemetry-python-0_5_0:1
    # arn:aws:lambda:us-east-1:184161586896:layer:opentelemetry-collector-amd64-0_5_0:1
    

    region - set your region
    version - use version from latest Otel OTel Lambda release
    amd64|arm64 - choose architecture

  2. In Atatus Dashboard navigate to Settings tab, then click on Account Settings. From there, go to API Keys. You can either generate a new API key or copy an existing one. After obtaining the API key, you'll need to set it in the atatus-collector.yaml file under the exporter otlphttp header (see step 3).

  3. Setup collector using the below steps

  • Establish an environment variable named OPENTELEMETRY_COLLECTOR_CONFIG_FILE=/var/task/atatus-collector.yaml within your Lambda function. This action instructs the extension on the location of the collector configuration.

  • You can optionally set the tags (env, service, and version - Optional) in the processors resource attributes. This helps with organizing all functions within a unified service, making filtering easier.

  • Please create a configuration file named as atatus-collector.yaml below:

    a. Place atatus-collector.yaml in the root directory.

    copy
    icon/buttons/copy
    receivers:
      otlp:
        protocols:
          http:
    
    processors:
      resource:
        attributes:
          - key: env
            value: "<YOUR_ENV>"
            action: upsert
          - key: service
            value: "<YOUR_SERVICE_NAME>"
            action: upsert
          - key: version
            value: "<YOUR_VERSION>"
            action: upsert
    
    exporters:
      otlphttp:
        endpoint: "https://otel-rx.atatus.com:443"
        headers:
          api-key: "YOUR_ATATUS_API_KEY"
    
    service:
      pipelines:
        traces:
          receivers: [otlp]
          processors: [resource]
          exporters: [otlphttp]
        metrics:
          receivers: [otlp]
          processors: [resource]
          exporters: [otlphttp]
    

    b. Configure the lambda function by setting the environment variables in the corresponding Serverless Environment.

    copy
    icon/buttons/copy
    AWS_LAMBDA_EXEC_WRAPPER: /opt/otel-instrument
    OPENTELEMETRY_COLLECTOR_CONFIG_FILE: /var/task/atatus-collector.yaml
    OTEL_PROPAGATORS: tracecontext
    OTEL_TRACES_SAMPLER: always_on
    

4. Deploy this file along with your Lambda function.