API: Getting timing information from job traces


This is a question after a fair amount of hunting. The starting point is a desire to know where my jobs are spending time, to eventually make changes to run faster.

I’m running on hosted gitlab.com, in a private project, but I think my question focuses on the API.

Trace APIs

What I want looks a lot like the trace displayed in the job detail webpage:

which internally calls this endpoint

and gets back an application/json response where some objects in the lines collection define a section_duration with the timing information I ultimately want.

The problem is that this is the web UI, and if possible I’d prefer to script getting this detail for many recent jobs from the API.

The API endpoint for jobs works

And though it’s not in the API docs, the trace API exists

However that endpoint returns text/plain and does not contain duration information. I’ve tried setting Accept: application/json but that did’t change behavior. I’ve also tried looking for job.log under artifacts, but it’s not visible there.

The Question

Summary: I’m interested in answers at either level: how are you getting detailed information of job timings, or is there a way to get the same json from the job/trace API?


Timestamps in job logs (trace) is a feature proposal tracked in Add timestamps to the CI logs for each line in the log (#202293) · Issues · GitLab.org / GitLab · GitLab

1 Like