Skip to content

lambda: AdotLambdaExecWrapper is incorrect for Python #24666

@Dilski

Description

@Dilski

Describe the bug

The ADOT Lambda auto-instrumentation does not work for python function, as the exec wrapper does not match the expected values for python adot

Expected Behavior

As per the ADOT documentation on auto-instumenting a python lambda function, the AWS_LAMBDA_EXEC_WRAPPER envar should be set to the value /opt/otel-instrument.

Current Behavior

The envar is set to one of 3 values, per the enum:

  REGULAR_HANDLER = '/opt/otel-handler',
  PROXY_HANDLER = '/opt/otel-proxy-handler',
  STREAM_HANDLER = '/opt/otel-stream-handler',

Reproduction Steps

new lambda.Function(this, "MyFunction", {
  runtime: lambda.Runtime.PYTHON_3_9,
  handler: "index.handler",
  code: lambda.Code.fromAsset(path.join(__dirname, "lambda-handler")),
  adotInstrumentation: {
    layerVersion: lambda.AdotLayerVersion.fromPythonSdkLayerVersion(
      lambda.AdotLambdaLayerPythonSdkVersion.LATEST
    ),
    execWrapper: lambda.AdotLambdaExecWrapper.REGULAR_HANDLER,
  },
});

Possible Solution

  • Provide an enum value that works for python (or a way to provide a custom value to match the type)
  • Detect python functions and just set the value to be /opt/otel-instrument
  • Work with ADOT to make the python value match other languages

Additional Information/Context

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.AdotInstrumentationConfig.html

CDK CLI Version

2.69

Framework Version

No response

Node.js Version

n/a

OS

n/a

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-lambdaRelated to AWS LambdabugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions