Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lambda: AdotLambdaExecWrapper is incorrect for Python #24666

Closed
Dilski opened this issue Mar 17, 2023 · 2 comments · Fixed by #26040
Closed

lambda: AdotLambdaExecWrapper is incorrect for Python #24666

Dilski opened this issue Mar 17, 2023 · 2 comments · Fixed by #26040
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@Dilski
Copy link

Dilski commented Mar 17, 2023

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

@Dilski Dilski added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 17, 2023
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Mar 17, 2023
@pahud
Copy link
Contributor

pahud commented Mar 17, 2023

Yes I can see the document requires AWS_LAMBDA_EXEC_WRAPPER to be set to /opt/otel-instrument for Lambda Python runtime.

Making this a p2. Any PR is highly welcome and appreciated!

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Mar 17, 2023
@mergify mergify bot closed this as completed in #26040 Jul 10, 2023
mergify bot pushed a commit that referenced this issue Jul 10, 2023
…support python lambda functions (#26040)

Small change to add an enum value to AdotLambdaExecWrapper. The python layer for adot requires the path *'/opt/otel-instrument'* which differs from the layer needed for other languages which is *'/opt/otel-handler'*. In the link below in the section **Enable auto-instrumentation for your Lambda function** step 5 requires the *'/opt/otel-instrument'* path. The existing work around is to provide a lambda layer yourself and the appropriate env variable for *AWS_LAMBDA_EXEC_WRAPPER* without using the adotInstrumentation parameters. This fix simplifies dev requirements.

[Python Lambda Otel](https://aws-otel.github.io/docs/getting-started/lambda/lambda-python)

Closes #24666.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

bmoffatt pushed a commit to bmoffatt/aws-cdk that referenced this issue Jul 29, 2023
…support python lambda functions (aws#26040)

Small change to add an enum value to AdotLambdaExecWrapper. The python layer for adot requires the path *'/opt/otel-instrument'* which differs from the layer needed for other languages which is *'/opt/otel-handler'*. In the link below in the section **Enable auto-instrumentation for your Lambda function** step 5 requires the *'/opt/otel-instrument'* path. The existing work around is to provide a lambda layer yourself and the appropriate env variable for *AWS_LAMBDA_EXEC_WRAPPER* without using the adotInstrumentation parameters. This fix simplifies dev requirements.

[Python Lambda Otel](https://aws-otel.github.io/docs/getting-started/lambda/lambda-python)

Closes aws#24666.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants