Skip to content

Commit

Permalink
fix(lambda): add instrument handler option to adotInstrumentation to …
Browse files Browse the repository at this point in the history
…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*
  • Loading branch information
randyridgley authored Jul 10, 2023
1 parent f9a1192 commit bd06669
Show file tree
Hide file tree
Showing 14 changed files with 309 additions and 199 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "22.0.0",
"version": "32.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "22.0.0",
"version": "32.0.0",
"files": {
"47696196003068eea2528656bebb8f11e163f75e8635d774b801bbc06a0e57e2": {
"da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86": {
"source": {
"path": "Stack1.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "47696196003068eea2528656bebb8f11e163f75e8635d774b801bbc06a0e57e2.json",
"objectKey": "da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
},
"Environment": {
"Variables": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
}
},
"Handler": "index.handler",
Expand Down Expand Up @@ -263,7 +263,7 @@
},
"Environment": {
"Variables": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
}
},
"Handler": "index.handler",
Expand Down Expand Up @@ -360,7 +360,7 @@
},
"Environment": {
"Variables": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
}
},
"Handler": "index.handler",
Expand Down Expand Up @@ -457,7 +457,7 @@
},
"Environment": {
"Variables": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
}
},
"Handler": "index.handler",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "22.0.0",
"version": "32.0.0",
"files": {
"a4926065bd63dad984b7b214cd689e14b56eeec5afba89f078cd5134f8304bd8": {
"a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5": {
"source": {
"path": "Stack2.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "a4926065bd63dad984b7b214cd689e14b56eeec5afba89f078cd5134f8304bd8.json",
"objectKey": "a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
},
"Environment": {
"Variables": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
}
},
"Handler": "index.handler",
Expand Down Expand Up @@ -266,7 +266,7 @@
},
"Environment": {
"Variables": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
}
},
"Handler": "index.handler",
Expand Down Expand Up @@ -363,7 +363,7 @@
},
"Environment": {
"Variables": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
}
},
"Handler": "index.handler",
Expand Down Expand Up @@ -460,7 +460,7 @@
},
"Environment": {
"Variables": {
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-handler"
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/otel-instrument"
}
},
"Handler": "index.handler",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"22.0.0"}
{"version":"32.0.0"}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "22.0.0",
"version": "32.0.0",
"testCases": {
"IntegTest/DefaultTest": {
"stacks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "22.0.0",
"version": "32.0.0",
"artifacts": {
"Stack1.assets": {
"type": "cdk:asset-manifest",
Expand All @@ -17,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/47696196003068eea2528656bebb8f11e163f75e8635d774b801bbc06a0e57e2.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/da818761c778b9099af670b7379d3db67a8f46572795cf76cc3f7442b341fb86.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -140,6 +140,33 @@
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
],
"MyFunc6ServiceRoleCDDBC2C6": [
{
"type": "aws:cdk:logicalId",
"data": "MyFunc6ServiceRoleCDDBC2C6",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
]
}
],
"MyFunc6ServiceRoleDefaultPolicyC4D4BF55": [
{
"type": "aws:cdk:logicalId",
"data": "MyFunc6ServiceRoleDefaultPolicyC4D4BF55",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
]
}
],
"MyFunc60D944984": [
{
"type": "aws:cdk:logicalId",
"data": "MyFunc60D944984",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
]
}
]
},
"displayName": "Stack1"
Expand All @@ -160,7 +187,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/a4926065bd63dad984b7b214cd689e14b56eeec5afba89f078cd5134f8304bd8.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/a4d1f60a1bf3af6d4d630d5c0557444ee8d18f93483887409a89dc8f34b228d5.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -277,6 +304,33 @@
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
],
"MyFunc6ServiceRoleCDDBC2C6": [
{
"type": "aws:cdk:logicalId",
"data": "MyFunc6ServiceRoleCDDBC2C6",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
]
}
],
"MyFunc6ServiceRoleDefaultPolicyC4D4BF55": [
{
"type": "aws:cdk:logicalId",
"data": "MyFunc6ServiceRoleDefaultPolicyC4D4BF55",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
]
}
],
"MyFunc60D944984": [
{
"type": "aws:cdk:logicalId",
"data": "MyFunc60D944984",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
]
}
]
},
"displayName": "Stack2"
Expand Down
Loading

0 comments on commit bd06669

Please sign in to comment.