Skip to content

Commit 56efdc7

Browse files
feiyangliu2023Feiyang Liu
andauthored
Adding metric of time since last CodeOSS version update in update automation workflow (#56)
* add NewReleaseDetected metric for monitoring upstream releases * Replace NewReleaseDetected metric with CodeOSSReleaseLag metric * add NewReleaseDetected metric for monitoring upstream releases * Replace NewReleaseDetected metric with CodeOSSReleaseLag metric * Changing normalized metric value from month to day --------- Co-authored-by: Feiyang Liu <[email protected]>
1 parent 9550f98 commit 56efdc7

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

.github/workflows/update-automation.yaml

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,52 @@ jobs:
404404
405405
echo "Created PR from ${{ needs.update-automation.outputs.staging-branch }} to $TARGET_BRANCH"
406406
407+
publish-release-lag-metric:
408+
name: Publish Release Lag Metric
409+
runs-on: ubuntu-latest
410+
needs: [update-automation]
411+
if: always()
412+
environment: update-automation-workflow-env
413+
permissions:
414+
id-token: write # Required for OIDC
415+
contents: read
416+
env:
417+
REPOSITORY: ${{ github.repository }}
418+
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
419+
steps:
420+
- name: Checkout code
421+
uses: actions/checkout@v4
422+
with:
423+
submodules: true
424+
fetch-depth: 1
425+
426+
- name: Use role credentials for metrics
427+
id: aws-creds
428+
uses: aws-actions/configure-aws-credentials@v4
429+
with:
430+
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }}
431+
aws-region: us-east-1
432+
433+
- name: Calculate and publish release lag metric
434+
if: steps.aws-creds.outcome == 'success'
435+
run: |
436+
cd third-party-src
437+
SUBMODULE_COMMIT_TIMESTAMP=$(git log -1 --format=%ct)
438+
cd ..
439+
440+
CURRENT_TIMESTAMP=$(date +%s)
441+
SECONDS_BEHIND=$((CURRENT_TIMESTAMP - SUBMODULE_COMMIT_TIMESTAMP))
442+
NORMALIZED_VALUE=$(awk "BEGIN {printf \"%.6f\", $SECONDS_BEHIND / 86400}")
443+
444+
aws cloudwatch put-metric-data \
445+
--namespace "GitHub/Workflows" \
446+
--metric-name "CodeOSSReleaseLag" \
447+
--dimensions "Repository=${{ env.REPOSITORY }},Workflow=UpdateAutomation" \
448+
--value $NORMALIZED_VALUE \
449+
--unit None
450+
451+
echo "Published metric: CodeOSSReleaseLag = $NORMALIZED_VALUE (equivalent to $NORMALIZED_VALUE days behind upstream)"
452+
407453
send-notification:
408454
name: Send Notification
409455
runs-on: ubuntu-latest
@@ -434,7 +480,7 @@ jobs:
434480
publish-success-metrics:
435481
name: Publish Success Metrics
436482
runs-on: ubuntu-latest
437-
needs: [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification]
483+
needs: [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification, publish-release-lag-metric]
438484
environment: update-automation-workflow-env
439485
if: always() && !failure() && !cancelled()
440486
permissions:
@@ -463,7 +509,7 @@ jobs:
463509
publish-failure-metrics:
464510
name: Publish Failure Metrics
465511
runs-on: ubuntu-latest
466-
needs: [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification]
512+
needs: [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification, publish-release-lag-metric]
467513
environment: update-automation-workflow-env
468514
if: failure()
469515
permissions:

0 commit comments

Comments
 (0)