Skip to content

Commit 7c9f852

Browse files
authored
[JavaScript] Add Performance Testing Workflow for Lambda Layer (#392)
**Issue description:** - Added input for language version runtime - Added a workflow to automatically performance test and gather the results for the unreleased JavaScript Lambda Layer. **The GitHub workflow does the following:** 1. Deploy and setup the JavaScript 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/14387543293
1 parent 1a7a511 commit 7c9f852

File tree

2 files changed

+127
-1
lines changed

2 files changed

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

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ on:
99
required: true
1010
default: 20
1111
type: number
12+
13+
python_version:
14+
description: 'The Python version to run the test'
15+
required: true
16+
default: '3.13'
17+
type: string
18+
1219
jobs:
1320
python-lambda-layer-performance-test:
1421
runs-on: ubuntu-latest
@@ -35,7 +42,7 @@ jobs:
3542
- name: Setup Python
3643
uses: actions/setup-python@v5
3744
with:
38-
python-version: '3.13'
45+
python-version: ${{ github.event.inputs.python_version }}
3946

4047
- name: Setup Terraform
4148
uses: hashicorp/setup-terraform@v2

0 commit comments

Comments
 (0)