generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 31
misc: collect ci metrics #1422
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
Merged
Merged
misc: collect ci metrics #1422
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7265fa1
collect CI metric
xinsong-cui d6e131a
retrigger CI
xinsong-cui 40459d6
use emit metric action
xinsong-cui 275da8f
use correct product name
xinsong-cui cd665fa
Merge branch 'main' into misc-smithy-ci-metrics
xinsong-cui 7f33b97
format
xinsong-cui 7371859
always calculate duration
xinsong-cui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| name: Workflow Metrics | ||
| description: > | ||
| Track and upload workflow metrics to CloudWatch | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| # will change this to AWS CI role before merging | ||
| role-to-assume: arn:aws:iam::886436966712:role/Admin | ||
| aws-region: us-west-2 | ||
| - name: Upload workflow metrics | ||
| shell: bash | ||
| run: | | ||
| # Determine build job name with matrix values | ||
| job_name="${{ github.job }}" | ||
| if [ ! -z "${{ matrix.java-version || '' }}" ]; then | ||
| job_name="${job_name}(${{ matrix.java-version }})" | ||
| fi | ||
| if [ ! -z "${{ matrix.os || '' }}" ]; then | ||
| job_name="${job_name}(${{ matrix.os }})" | ||
| fi | ||
|
|
||
| # Determine success/failure (1 for success, 0 for failure) | ||
| if [ "${{ job.status }}" == "success" ]; then | ||
| success_value=1 | ||
| else | ||
| success_value=0 | ||
| fi | ||
|
|
||
| # Determine branch (PR target branch or current branch) | ||
| if [ ! -z "${{ github.base_ref }}" ]; then | ||
| branch_name="${{ github.base_ref }}" | ||
| else | ||
| branch_name="${{ github.ref_name }}" | ||
| fi | ||
|
|
||
| aws cloudwatch put-metric-data \ | ||
| --namespace "GitHub/Workflows" \ | ||
| --metric-data '[{ | ||
| "MetricName": "Success", | ||
| "Value": '$success_value', | ||
| "Unit": "Count", | ||
| "Dimensions": [ | ||
| { | ||
| "Name": "WorkflowName", | ||
| "Value": "${{ github.workflow }}" | ||
| }, | ||
| { | ||
| "Name": "JobName", | ||
| "Value": "'$job_name'" | ||
| }, | ||
| { | ||
| "Name": "Repository", | ||
| "Value": "${{ github.repository }}" | ||
| }, | ||
| { | ||
| "Name": "Branch", | ||
| "Value": "'$branch_name'" | ||
| } | ||
| ] | ||
| }]' | ||
|
|
||
| if [ -z "$WORKFLOW_START_TIME" ]; then | ||
| echo "Warning: WORKFLOW_START_TIME not set, skipping metrics upload" | ||
| exit 0 | ||
| fi | ||
|
|
||
| duration=$(($(date +%s) - $WORKFLOW_START_TIME)) | ||
|
|
||
| # Only track duration for successful workflows | ||
| if [ "$success_value" -eq 1 ]; then | ||
| aws cloudwatch put-metric-data \ | ||
| --namespace "GitHub/Workflows" \ | ||
| --metric-data '[{ | ||
| "MetricName": "Duration", | ||
| "Value": '$duration', | ||
| "Unit": "Seconds", | ||
| "Dimensions": [ | ||
| { | ||
| "Name": "WorkflowName", | ||
| "Value": "${{ github.workflow }}" | ||
| }, | ||
| { | ||
| "Name": "JobName", | ||
| "Value": "'$job_name'" | ||
| }, | ||
| { | ||
| "Name": "Repository", | ||
| "Value": "${{ github.repository }}" | ||
| }, | ||
| { | ||
| "Name": "Branch", | ||
| "Value": "'$branch_name'" | ||
| } | ||
| ] | ||
| }]' | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.