@@ -404,35 +404,52 @@ jobs:
404404
405405 echo "Created PR from ${{ needs.update-automation.outputs.staging-branch }} to $TARGET_BRANCH"
406406
407- publish-new- release-detected :
408- name : Publish New Release Detected Metric
407+ publish-release-lag-metric :
408+ name : Publish Release Lag Metric
409409 runs-on : ubuntu-latest
410410 needs : [update-automation]
411- if : needs.update-automation.outputs.staging-branch != ''
411+ if : always()
412412 environment : update-automation-workflow-env
413413 permissions :
414414 id-token : write # Required for OIDC
415+ contents : read
415416 env :
416417 REPOSITORY : ${{ github.repository }}
417418 AWS_ROLE_TO_ASSUME : ${{ secrets.AWS_ROLE_TO_ASSUME }}
418419 steps :
420+ - name : Checkout code
421+ uses : actions/checkout@v4
422+ with :
423+ submodules : true
424+ fetch-depth : 1
425+
419426 - name : Use role credentials for metrics
420427 id : aws-creds
421428 uses : aws-actions/configure-aws-credentials@v4
422429 with :
423430 role-to-assume : ${{ env.AWS_ROLE_TO_ASSUME }}
424431 aws-region : us-east-1
425- - name : Publish new release detected metric
432+
433+ - name : Calculate and publish release lag metric
426434 if : steps.aws-creds.outcome == 'success'
427435 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 / 2592000}")
443+
428444 aws cloudwatch put-metric-data \
429445 --namespace "GitHub/Workflows" \
430- --metric-name "NewReleaseDetected " \
446+ --metric-name "CodeOSSReleaseLag " \
431447 --dimensions "Repository=${{ env.REPOSITORY }},Workflow=UpdateAutomation" \
432- --value 1 \
433- --timestamp $(date -u +%Y-%m-%dT%H:%M:%S.000Z)
448+ --value $NORMALIZED_VALUE \
449+ --unit None
434450
435- echo "Published metric: NewReleaseDetected for version ${{ needs.update-automation.outputs.latest-code-oss-tag }}"
451+ DAYS_BEHIND=$((SECONDS_BEHIND / 86400))
452+ echo "Published metric: CodeOSSReleaseLag = $NORMALIZED_VALUE (equivalent to $DAYS_BEHIND days behind upstream)"
436453
437454 send-notification :
438455 name : Send Notification
@@ -464,7 +481,7 @@ jobs:
464481 publish-success-metrics :
465482 name : Publish Success Metrics
466483 runs-on : ubuntu-latest
467- needs : [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification, publish-new- release-detected ]
484+ needs : [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification, publish-release-lag-metric ]
468485 environment : update-automation-workflow-env
469486 if : always() && !failure() && !cancelled()
470487 permissions :
@@ -493,7 +510,7 @@ jobs:
493510 publish-failure-metrics :
494511 name : Publish Failure Metrics
495512 runs-on : ubuntu-latest
496- needs : [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification, publish-new- release-detected ]
513+ needs : [update-automation, build-and-update-package-locks, generate-oss-attribution, create-pr, send-notification, publish-release-lag-metric ]
497514 environment : update-automation-workflow-env
498515 if : failure()
499516 permissions :
0 commit comments