Skip to content

Commit 6cb1802

Browse files
authored
[Java] Add Performance Testing Workflow for Lambda Layer (#394)
**Issue description:** - Added a workflow to automatically performance test and gather the results for the unreleased Java Lambda Layer. **The GitHub workflow does the following:** 1. Deploy and setup the Java Lambda sample application instrumented with the Application Signals Lambda Layer on the AppSignals e2e testing aws account. 2. Record the start time of the test and run the specified amount (default: 20) Lambda cold start iterations on the sample application 3. Record the end time of the test 4. Query CW Logs Insights for the aggregated performance testing metrics with the following query: ``` fields @timestamp, @message, @initDuration | filter @message like "REPORT RequestId" | stats count(@initDuration) as Sample_Count, avg(@initDuration) as Average_Init_Duration, min(@initDuration) as Min_Init_Duration, max(@initDuration) as Max_Init_Duration, pct(@initDuration, 50) as P50_Init_Duration, pct(@initDuration, 90) as P90_Init_Duration, pct(@initDuration, 99) as P99_Init_Duration' ``` 5. Parse and flatten the result from the query call and save it in a file. 6. Clean and destroy the deployed lambda resources upon completion, cancellation, or failure. **Testing** Testing was done on a personal aws dev account with the exact IAM permissions as the e2e testing aws account. Example of a successful job: https://github.com/liustve/aws-application-signals-test-framework/actions/runs/14392326689
1 parent ff9e0b7 commit 6cb1802

File tree

2 files changed

+129
-1
lines changed

2 files changed

+129
-1
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
4+
name: Java Lambda Layer Performance Test
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
test_runs:
9+
description: 'Number of test runs to perform'
10+
required: true
11+
default: 20
12+
type: number
13+
14+
java_version:
15+
description: 'The Java version to run the test'
16+
required: true
17+
default: '17'
18+
type: string
19+
20+
jobs:
21+
java-lambda-layer-performance-test:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
id-token: write
25+
contents: read
26+
27+
env:
28+
NUM_TEST_RUNS: ${{ github.event.inputs.test_runs }}
29+
30+
steps:
31+
- name: Configure AWS Credentials
32+
uses: aws-actions/configure-aws-credentials@v4
33+
with:
34+
role-to-assume: arn:aws:iam::${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }}:role/${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME }}
35+
aws-region: us-east-1
36+
37+
- name: Checkout aws-otel-java-instrumentation
38+
uses: actions/checkout@v4
39+
with:
40+
repository: aws-observability/aws-otel-java-instrumentation
41+
ref: release/v1.33.x
42+
path: aws-otel-java-instrumentation
43+
44+
- name: Setup Terraform
45+
uses: hashicorp/setup-terraform@v2
46+
47+
- name: Build and Deploy Lambda Layer
48+
run: |
49+
cd aws-otel-java-instrumentation/lambda-layer
50+
chmod +x build-layer.sh
51+
./build-layer.sh
52+
53+
LAYER_VERSION_ARN=$(aws lambda publish-layer-version \
54+
--layer-name AWSOpenTelemetryDistroJava \
55+
--zip-file fileb://build/distributions/aws-opentelemetry-java-layer.zip \
56+
--compatible-runtimes "java11" "java17" "java21" \
57+
--compatible-architectures "x86_64" "arm64" \
58+
--query 'LayerVersionArn' \
59+
--output text)
60+
61+
echo "LAYER_VERSION_ARN=$LAYER_VERSION_ARN" >> $GITHUB_ENV
62+
echo "Published layer ARN $LAYER_VERSION_ARN"
63+
64+
- name: Build and Deploy Sample Application with Lambda Layer
65+
run: |
66+
cd aws-otel-java-instrumentation/sample-apps/apigateway-lambda
67+
gradle clean build
68+
gradle createLambdaZip
69+
70+
cd terraform
71+
terraform init
72+
terraform apply -auto-approve -var "adot_layer_arn=${{ env.LAYER_VERSION_ARN }}"
73+
74+
- name: Checkout current repository
75+
uses: actions/checkout@v4
76+
with:
77+
path: current-repo
78+
79+
- name: Run Cold Start Iterations for Base Lambda + Lambda Layer
80+
run: |
81+
cd current-repo
82+
chmod +x lambda-layer-perf-test/lambda-layer-run.sh
83+
./lambda-layer-perf-test/lambda-layer-run.sh false aws-opentelemetry-distro-java
84+
85+
- name: Remove Application Signals Lambda Layer
86+
run: |
87+
echo "Removing Lambda layer..."
88+
89+
OUTPUT=$(aws lambda update-function-configuration \
90+
--function-name aws-opentelemetry-distro-java \
91+
--layers [])
92+
93+
echo "Lambda configuration:"
94+
echo "$OUTPUT"
95+
96+
LAYERS=$(echo "$OUTPUT" | jq -r '.Layers | length')
97+
98+
if [ "$LAYERS" -ne 0 ]; then
99+
echo "::error::Found $LAYERS layer(s) still attached to the function"
100+
echo "::error::Layer details:"
101+
echo "$OUTPUT" | jq -r '.Layers'
102+
exit 1
103+
else
104+
echo "✅ Layers successfully removed"
105+
fi
106+
107+
- name: Run Cold Start Iterations for Base Lambda
108+
run: |
109+
cd current-repo
110+
chmod +x lambda-layer-perf-test/lambda-layer-run.sh
111+
./lambda-layer-perf-test/lambda-layer-run.sh true aws-opentelemetry-distro-java
112+
113+
- name: Upload test results
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: java-performance-test-results
117+
path: |
118+
no_layer_results.txt
119+
layer_results.txt
120+
retention-days: 90
121+
122+
- name: Cleanup Terraform Resources
123+
if: success() || failure() || cancelled()
124+
run: |
125+
cd aws-otel-java-instrumentation/sample-apps/apigateway-lambda/terraform
126+
echo "Starting Terraform cleanup..."
127+
terraform init
128+
terraform destroy -auto-approve

.github/workflows/python-lambda-layer-perf-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
required: true
1010
default: 20
1111
type: number
12-
12+
1313
python_version:
1414
description: 'The Python version to run the test'
1515
required: true

0 commit comments

Comments
 (0)