Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 24
fix: update queue duration calculation#752
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
base:main
Are you sure you want to change the base?
Changes from all commits
061fa2d23fd33cf3751e0b3e6d0bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -550,7 +550,11 @@ def _issue_runner_start( | ||
| else float("inf") | ||
| ) | ||
| RUNNER_IDLE_DURATION_SECONDS.labels(flavor).observe(idle_duration) | ||
| queue_duration = job_metrics.queue_duration if job_metrics else float("inf") | ||
| queue_duration = ( | ||
| job_metrics.queue_duration | ||
| if job_metrics and job_metrics.queue_duration is not None | ||
| else float("inf") | ||
| ) | ||
| RUNNER_QUEUE_DURATION_SECONDS.labels(flavor).observe(queue_duration) | ||
| return metric_events.RunnerStart | ||
| @@ -614,14 +618,18 @@ def _create_runner_start( | ||
| pre_job_metrics.timestamp - (runner_metrics.installation_end_timestamp or 0), 0 | ||
| ) | ||
| # GitHub API returns started_at < created_at in some rare cases. | ||
| if job_metrics and job_metrics.queue_duration < 0: | ||
| # GitHub API returns started_at < queued_at in some rare cases. | ||
| if job_metrics and job_metrics.queue_duration is not None and job_metrics.queue_duration < 0: | ||
| logger.warning( | ||
| "Queue duration for runner %s is negative: %f. Setting it to zero.", | ||
| runner_metrics.instance_id, | ||
| job_metrics.queue_duration, | ||
| ) | ||
| queue_duration = max(job_metrics.queue_duration, 0) if job_metrics else None | ||
| queue_duration = ( | ||
| max(job_metrics.queue_duration, 0) | ||
| if job_metrics and job_metrics.queue_duration is not None | ||
| else None | ||
| ) | ||
Comment on lines
553
to
+632
Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new Could you add cases constructing 🤖 AI-assisted | ||
| return metric_events.RunnerStart( | ||
| timestamp=pre_job_metrics.timestamp, | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GitHub Actions Jobs REST API ("Get a job for a workflow run") doesn't return a
queued_atfield at all — its response schema only hascreated_at/started_at/completed_at. That meansjob.get("queued_at")here always evaluates toNonein production.As a result,
queued_or_created_at = job_info.queued_at or job_info.created_atinmetrics/github.py:53will always fall back tocreated_at, so the queue-duration value is unchanged from before this PR. The PR's stated goal — measuring queue duration from the true queue-entry timestamp — isn't actually achieved; only the missing-started_athandling is a real behavioral change. This is easy to miss because every unit test injects a syntheticqueued_atkey into the mocked response, so the suite can't detect the divergence from the real API shape.Either drop the
queued_atplumbing and scope this PR to the missing-started_atfix, or call out explicitly in the PR description that GitHub doesn't currently expose this field and the plumbing is forward-looking for a future data source (e.g. aworkflow_jobwebhook payload, if that's the intent).🤖 AI-assisted