Skip to content

WIP: Move lograge logging from controller to middleware

Balakumar requested to merge sribalakumar/gitlab-ce:log_cpu_time into master

We are using Lograge to log to $env_json.log and Lograge works by attaching to :action_controller using ActiveSupport::Notifications.

Draw back with this approach is -

  1. It does not log requests which are returning/erroring from Middleware. https://github.com/roidrage/lograge/issues/48
  2. Duration logged in reality is controller_duration not the actual request_duration.

Proposal

Patch Lograge to log from Middleware.

Other changes to log payload

As part of moving to middleware, also including other performance related information corresponding to the request - cpu_system_ms, cpu_user_ms, cpu_total_ms, objects_allocated which should close https://gitlab.com/gitlab-org/gitlab-ce/issues/65388

Example of new log looks like -

{"method":"GET","path":"/","format":"*/*","controller":"RootController","action":"index","status":302,"duration":91.743,"view":0.0,"db":0.0,"location":"http://localhost:3000/users/sign_in","params":[],"user_id":null,"username":null,"correlation_id":"mvyvMK5K3d7","controller_duration":12.85,"objects_allocated":55623,"time":"2019-08-18T14:42:48.277Z","remote_ip":"127.0.0.1","ua":"curl/7.52.1","queue_duration":75.62,"cpu_system_ms":46.24,"cpu_user_ms":45.1,"cpu_total_ms":91.34}

Todo

Since there is a log payload change, there will be a document change required for https://docs.gitlab.com/ee/administration/logs.html#production_jsonlog

Edited by Balakumar

Merge request reports