Skip to content

Commit 15a4e52

Browse files
authored
Send main build metrics (#1127)
*Issue #, if available:* *Description of changes:* Emit a failure metric if main build fails. Since this workflow is triggered with pushes to main or a release branch, we want to be notified if there is a failure with the build process or e2e tests. Tested by temporarily adding an on: push: trigger to my own branch in this repo and testing the updated workflow. Verified that failure metric was successfully published to cloudwatch. https://github.com/aws-observability/aws-otel-java-instrumentation/actions/runs/16783145872 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 2d6a521 commit 15a4e52

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

.github/workflows/e2e-tests-app-with-java-agent.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,18 @@ jobs:
167167
VALIDATOR_COMMAND: -c spark-otel-trace-metric-validation.yml --endpoint http://app:4567 --metric-namespace aws-otel-integ-test -t ${{ github.run_id }}-${{ github.run_number }}
168168

169169
# publish status
170-
publish-build-status:
171-
needs: [ test_Spring_App_With_Java_Agent, test_Spark_App_With_Java_Agent, test_Spark_AWS_SDK_V1_App_With_Java_Agent ]
172-
if: ${{ always() }}
173-
uses: ./.github/workflows/publish-status.yml
174-
with:
175-
namespace: 'ADOT/GitHubActions'
176-
repository: ${{ github.repository }}
177-
branch: ${{ github.ref_name }}
178-
workflow: ${{ inputs.caller-workflow-name }}
179-
success: ${{ needs.test_Spring_App_With_Java_Agent.result == 'success' &&
180-
needs.test_Spark_App_With_Java_Agent.result == 'success' &&
181-
needs.test_Spark_AWS_SDK_V1_App_With_Java_Agent.result == 'success' }}
182-
region: us-east-1
183-
secrets:
184-
roleArn: ${{ secrets.METRICS_ROLE_ARN }}
170+
# publish-build-status:
171+
# needs: [ test_Spring_App_With_Java_Agent, test_Spark_App_With_Java_Agent, test_Spark_AWS_SDK_V1_App_With_Java_Agent ]
172+
# if: ${{ always() }}
173+
# uses: ./.github/workflows/publish-status.yml
174+
# with:
175+
# namespace: 'ADOT/GitHubActions'
176+
# repository: ${{ github.repository }}
177+
# branch: ${{ github.ref_name }}
178+
# workflow: ${{ inputs.caller-workflow-name }}
179+
# success: ${{ needs.test_Spring_App_With_Java_Agent.result == 'success' &&
180+
# needs.test_Spark_App_With_Java_Agent.result == 'success' &&
181+
# needs.test_Spark_AWS_SDK_V1_App_With_Java_Agent.result == 'success' }}
182+
# region: us-east-1
183+
# secrets:
184+
# roleArn: ${{ secrets.METRICS_ROLE_ARN }}

.github/workflows/main-build.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,22 @@ jobs:
263263
adot-image-name: ${{ needs.build.outputs.staging-image }}
264264

265265
publish-build-status:
266-
needs: [ build, contract-tests ]
267-
if: ${{ always() }}
268-
uses: ./.github/workflows/publish-status.yml
269-
with:
270-
namespace: 'ADOT/GitHubActions'
271-
repository: ${{ github.repository }}
272-
branch: ${{ github.ref_name }}
273-
workflow: main-build
274-
success: ${{ needs.build.result == 'success' &&
275-
needs.contract-tests.result == 'success' }}
276-
region: us-east-1
277-
secrets:
278-
roleArn: ${{ secrets.METRICS_ROLE_ARN }}
266+
name: "Publish Main Build Status"
267+
needs: [ build, e2e-test, contract-tests, application-signals-lambda-layer-build, application-signals-e2e-test ]
268+
runs-on: ubuntu-latest
269+
if: always()
270+
steps:
271+
- name: Configure AWS Credentials for emitting metrics
272+
uses: aws-actions/configure-aws-credentials@v4
273+
with:
274+
role-to-assume: ${{ secrets.METRICS_ROLE_ARN }}
275+
aws-region: us-east-1
276+
277+
- name: Publish main build status
278+
run: |
279+
value="${{ needs.build.result == 'success' && needs.e2e-test.result == 'success' && needs.contract-tests.result == 'success' \
280+
&& needs.application-signals-lambda-layer-build.result == 'success' && \needs.application-signals-e2e-test.result == 'success' && '0.0' || '1.0'}}"
281+
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
282+
--metric-name Failure \
283+
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=main_build \
284+
--value $value

0 commit comments

Comments
 (0)