Properly calculate job wait/run time in pipeline_performance metric.
The code uses RunnableAt instead of CreatedAt as starting point in order to not include any periods of time that are spent waiting on previous tasks.
We're only interested in waiting times caused by the unavailability of agents.
@@ -47,7 +47,7 @@ func (pp *PipelinePerformance) Collect() (data.DataSet, error) {
continue
}
- err := result.AddRow(pipeline.Org, pipeline.Slug, *build.Number, *job.Name, job.CreatedAt.Time, getDifferenceSeconds(job.CreatedAt, job.StartedAt), getDifferenceSeconds(job.StartedAt, job.FinishedAt), skippedTasks)
+ err := result.AddRow(pipeline.Org, pipeline.Slug, *build.Number, *job.Name, job.RunnableAt.Time, getDifferenceSeconds(job.RunnableAt, job.StartedAt), getDifferenceSeconds(job.StartedAt, job.FinishedAt), skippedTasks)
if err != nil {
return nil, fmt.Errorf("Failed to add result for job %s of build %d: %v", *job.Name, *build.Number, err)
}
