Skip to content

Add structured logging for ActionCable

Heinrich Lee Yu requested to merge 217313-upgrade-lograge into master

What does this MR do?

Upgrades lograge to support ActionCable and overrides payload to include extra information.

Sample logs:

{"method":{},"path":{},"format":{},"params":[],"controller":"ApplicationCable::Connection","action":"connect","status":200,"time":"2020-05-14T19:46:21.647Z","remote_ip":"127.0.0.1","user_id":null,"username":null,"ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:76.0) Gecko/20100101 Firefox/76.0","queue_duration_s":null,"correlation_id":"jSOIEynHCUa","db_duration_s":0.0,"view_duration_s":0.0,"duration_s":0.11192}
{"method":{},"path":{},"format":{},"params":[{"key":"project_path","value":"flightjs/flight"},{"key":"iid","value":"38"}],"controller":"IssuesChannel","action":"subscribe","status":200,"time":"2020-05-14T19:46:22.008Z","remote_ip":"127.0.0.1","user_id":1,"username":"root","ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:76.0) Gecko/20100101 Firefox/76.0","queue_duration_s":null,"correlation_id":"jSOIEynHCUa","db_duration_s":0.0,"view_duration_s":0.0,"duration_s":0.32566}
{"method":{},"path":{},"format":{},"params":[{"key":"project_path","value":"flightjs/flight"},{"key":"iid","value":"38"}],"controller":"IssuesChannel","action":"unsubscribe","status":200,"time":"2020-05-14T19:47:29.179Z","remote_ip":"127.0.0.1","user_id":1,"username":"root","ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:76.0) Gecko/20100101 Firefox/76.0","queue_duration_s":null,"correlation_id":"jSOIEynHCUa","db_duration_s":0.0,"view_duration_s":0.0,"duration_s":0.00137}
{"method":{},"path":{},"format":{},"params":[],"controller":"ApplicationCable::Connection","action":"disconnect","status":200,"time":"2020-05-14T19:47:29.180Z","remote_ip":"127.0.0.1","user_id":1,"username":"root","ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:76.0) Gecko/20100101 Firefox/76.0","queue_duration_s":null,"correlation_id":"jSOIEynHCUa","db_duration_s":0.0,"view_duration_s":0.0,"duration_s":0.00527}

#217313 (closed)

Testing locally

  1. Enable the broadcast_issue_updates and real_time_issue_sidebar feature flags
  2. Open an issue page and it should connect and subscribe to a channel and you should see log output
  3. Navigate to another page / close the tab and you should see the unsubscribe and disconnect events logged

For future iterations

  1. db_duration_s is always 0 right now.
  2. Lograge currently does not hook into broadcast events. So those are currently not logged.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Heinrich Lee Yu

Merge request reports