Skip to content

Log metadata from requests

Bob Van Landuyt requested to merge bvl-log-metadata-rails into master

What does this MR do?

This adds the meta.* fields from Labkit::Context to the logs for rails and the api.

This also avoids generating queries from our logs, meaning that in some cases the plan information would not be available.

Related to gitlab-com/gl-infra/scalability#68 (closed)

Examples

API:

{"time":"2020-05-06T10:38:19.368Z","severity":"INFO","duration_s":0.37849,"db_duration_s":0.02107,"view_duration_s":0.35742,"status":200,"method":"GET","path":"/api/v4/features","params":[],"host":"localhost","remote_ip":"127.0.0.1","ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:76.0) Gecko/20100101 Firefox/76.0","route":"/api/:version/features","queue_duration_s":20.927064,"redis_calls":14,"redis_duration_s":0.013014,"correlation_id":"VRBiQCqydA8","meta.user":"root","meta.caller_id":"/api/:version/features"}

Web:

{"method":"GET","path":"/","format":"html","controller":"RootController","action":"index","status":200,"time":"2020-05-06T09:31:00.039Z","params":[],"remote_ip":"127.0.0.1","user_id":1,"username":"root","ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:76.0) Gecko/20100101 Firefox/76.0","queue_duration_s":0.217213,"correlation_id":"2CKVdbsyca9","meta.user":"root","meta.caller_id":"RootController#index","gitaly_calls":13,"gitaly_duration_s":0.070923,"redis_calls":87,"redis_duration_s":0.155781,"cpu_s":15.14,"db_duration_s":0.09969,"view_duration_s":2.51219,"duration_s":11.46788}
{"method":"GET","path":"/-/peek/results","format":"json","controller":"Peek::ResultsController","action":"show","status":200,"time":"2020-05-06T09:31:03.241Z","params":[{"key":"request_id","value":"2CKVdbsyca9"}],"remote_ip":"127.0.0.1","user_id":1,"username":"root","ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:76.0) Gecko/20100101 Firefox/76.0","queue_duration_s":0.10111,"correlation_id":"qcBb6SxtE85","meta.user":"root","meta.caller_id":"Peek::ResultsController#show","redis_calls":5,"redis_duration_s":0.031849,"cpu_s":0.51,"db_duration_s":0.01487,"view_duration_s":0.00022,"duration_s":0.39572}

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Bob Van Landuyt

Merge request reports