feat(log): log context metadata from upstream
When the upstream provides context metadata in X-Gitlab-Meta-*
headers, extract those values and insert them into the access log,
prefixed with meta.
.
To test this:
-
Check out gitlab!49824 (closed) in the Rails app.
-
Make Workhorse use this branch (
replace
in Workhorse'sgo.mod
). -
Make sure to set Workhorse to use JSON logging: gitlab-development-kit!1738 (merged)
-
curl -I localhost:3000/api/v4/users/1
will put this in the Workhorse log:{"content_type":"application/json","correlation_id":"01ETN31PV9E47BVKP8KRER7029","duration_ms":221,"host":"localhost:3000","level":"info","meta.caller_id":"/api/:version/users/:id","meta.feature_category":"users","method":"HEAD","msg":"access","proto":"HTTP/1.1","referrer":"","remote_addr":"127.0.0.1:60105","remote_ip":"127.0.0.1","route":"^/api/","status":401,"system":"http","time":"2020-12-28T16:31:37Z","ttfb_ms":221,"uri":"/api/v4/users/1","user_agent":"curl/7.64.1","written_bytes":0}
Edited by Sean McGivern