Skip to content

Commit

Permalink
Fix queue time calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
erwan-b committed Jun 9, 2022
1 parent 8e105c2 commit fc3ff25
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gh_actions_exporter/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,6 @@ def handle_job_duration(self, webhook: WebHook):
- webhook.workflow_job.started_at.timestamp())
self.job_duration.labels(**labels).observe(duration)
elif webhook.workflow_job.status == "in_progress":
duration = (webhook.workflow_job.steps[0].completed_at.timestamp()
duration = (webhook.workflow_job.steps[0].started_at.timestamp()
- webhook.workflow_job.started_at.timestamp())
self.job_start_duration.labels(**labels).observe(duration)
4 changes: 2 additions & 2 deletions tests/api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def workflow_job():
"status": "in_progress",
"conclusion": None,
"number": 1,
"started_at": "2021-11-29T14:46:57Z",
"completed_at": "2021-11-29T14:54:57Z"
"started_at": "2021-11-29T14:50:57Z",
"completed_at": None
}
],
"labels": ["github-hosted"]
Expand Down
4 changes: 2 additions & 2 deletions tests/api/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_workflow_job_in_progress(client, workflow_job, headers):
if 'inprogress_count_total{' in line:
assert "1.0" in line
if 'start_duration_seconds_sum{' in line:
assert '480.0' in line
assert '240.0' in line


def test_workflow_job_label_self_hosted(client, workflow_job, headers):
Expand Down Expand Up @@ -56,4 +56,4 @@ def test_multiple_job_runs(client, workflow_job, headers):
if 'job_total_count_total{' in line:
assert '1.0' in line
if 'job_start_duration_seconds_sum{' in line:
assert '480.0' in line
assert '240.0' in line

0 comments on commit fc3ff25

Please sign in to comment.