Skip to content

Fix job duration value when in log format is json

Steve Xuereb requested to merge fix-job-duration-json-format into master

What does this MR do?

Fix job duration value when in log format is json and specify the type of value it is

Why was this MR needed?

When the log_format is set to json the job duration is printed in nano seconds like below which isn't very clear. Transform the duration into seconds so it's easier to parse and also clear what the unit is.

{"duration":10170885466,"job":2126,"level":"info","msg":"Job succeeded","project":20,"runner":"4B72igtx","time":"2021-03-01T15:03:57+01:00"}

What's the best way to test this MR?

  1. Start gitlab-runner with -log-format=json: go run main.go -log-format=json run -c $GDKPATH/gitlab-runner-config.toml
  2. Run job.
log_format before after
runner Screenshot_2021-03-01_at_15.15.34 Screenshot_2021-03-11_at_09.18.23
json Screenshot_2021-03-01_at_15.16.00 Screenshot_2021-03-11_at_09.19.15
text Screenshot_2021-03-01_at_15.17.56 Screenshot_2021-03-11_at_09.20.02

What are the relevant issue numbers?

Whilst debugging gitlab-com/gl-infra/production#3800 (closed)

Edited by Steve Xuereb

Merge request reports