Expose job trace section detail via the API
Problem to solve
When managing a large CI platform it can be useful to understand how long is spent in CI jobs at each stage. I'm currently looking at trying to reduce the amount of time jobs spend waiting for a pod to be scheduled in our EKS cluster for CI and have a few things I can do to play with that but also want to be able to work out if changes are useful or not.
The database has the table ci_build_trace_sections
which allows us to find the amount of time that was spent at each section (this looks to be the time shown in the section summaries in the non raw build traces) and joining it against ci_build_trace_section_names
shows that the time elapsed waiting for a pod to be scheduled is in the prepare_script
stage.
Running the following query then gives me the time taken for each job to prepare the pod for today:
SELECT sections.project_id, build_id, EXTRACT(EPOCH FROM (date_end - date_start)) AS time_elapsed_seconds
FROM ci_build_trace_sections AS sections
INNER JOIN ci_build_trace_section_names AS section_names ON section_name_id = section_names.id
WHERE name = 'prepare_script' and date_start >= now::date;
Unfortunately I can't easily run reports directly against the database because that involves SSHing into our Omnibus instance and then running sudo gitlab-psql -d gitlabhq_production
. If this data was exposed via the API then I could query it much more easily.
Intended users
User experience goal
The user should be able to use the API to get at the trace details timing data.
Proposal
Further details
Permissions and Security
Should just need the same permissions as reading the job and trace details.