Skip to content

Fix job execution duration when runner assign time is not set#4472

Open
nikola-jokic wants to merge 2 commits intomasterfrom
nikola-jokic/no-runner-assigned-time-job-completed
Open

Fix job execution duration when runner assign time is not set#4472
nikola-jokic wants to merge 2 commits intomasterfrom
nikola-jokic/no-runner-assigned-time-job-completed

Conversation

@nikola-jokic
Copy link
Copy Markdown
Collaborator

@nikola-jokic nikola-jokic commented Apr 24, 2026

Fixes #4444
Fixes #3731

Copilot AI review requested due to automatic review settings April 24, 2026 08:23
@nikola-jokic nikola-jokic added the gha-runner-scale-set Related to the gha-runner-scale-set mode label Apr 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Hello! Thank you for your contribution.

Please review our contribution guidelines to understand the project's testing and code conventions.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an edge case in gha_job_execution_duration_seconds where jobs completed before runner assignment could yield an epoch-sized duration.

Changes:

  • Add a RunnerAssignTime.IsZero() check when computing job execution duration.
  • Record an execution duration of 0 when the runner was never assigned.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/ghalistener/metrics/metrics.go Outdated
Comment thread cmd/ghalistener/metrics/metrics.go Outdated
Comment on lines 501 to 506
var executionDuration int64
if !msg.RunnerAssignTime.IsZero() {
executionDuration = msg.FinishTime.Unix() - msg.RunnerAssignTime.Unix()
}

e.observeHistogram(MetricJobExecutionDurationSeconds, l, float64(executionDuration))
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change fixes a production-facing metric edge case, but there are currently no unit tests covering RecordJobCompleted. Please add a test for the zero RunnerAssignTime scenario to ensure we don’t regress back to recording an epoch-sized duration (and to lock in the intended behavior: either skipping the observation or recording a specific value).

Copilot uses AI. Check for mistakes.
Comment thread cmd/ghalistener/metrics/metrics.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/ghalistener/metrics/metrics.go Outdated
Comment thread cmd/ghalistener/metrics/metrics.go Outdated
@nikola-jokic nikola-jokic force-pushed the nikola-jokic/no-runner-assigned-time-job-completed branch from 83f6619 to 74bce34 Compare April 29, 2026 21:59
@nikola-jokic nikola-jokic requested a review from Copilot April 29, 2026 21:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gha-runner-scale-set Related to the gha-runner-scale-set mode

Projects

None yet

2 participants