Add structured logging for ActionCable
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}
Testing locally
- Enable the
broadcast_issue_updates
andreal_time_issue_sidebar
feature flags - Open an issue page and it should connect and subscribe to a channel and you should see log output
- Navigate to another page / close the tab and you should see the unsubscribe and disconnect events logged
For future iterations
-
db_duration_s
is always 0 right now. - Lograge currently does not hook into broadcast events. So those are currently not logged.
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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