How to Track Time Spent on Artifact and Cache Management in GitLab CI Jobs?

Problem to solve

During the execution time of a job, there is a loading time for the runner configuration; likewise, at the end, artifacts and cache are usually archived and uploaded to some hosting for later use. In order to determine the efficiency of the runner, it is convenient to know what percentage of the time the runner is executing tasks associated with the operation of the pipeline and instead of the sections that are specified in before_script, script and after_script.

At the moment, the only metrics that look related to what I’m looking for are: gitlab_runner_job_duration_seconds and gitlab_runner_job_queue_duration_seconds. These two metrics alone do not allow us to know how much time of the job was used to manage artifacts or cache.

References: