Skip to content

feat(log): log context metadata from upstream

Sean McGivern requested to merge log-context-metadata-from-upstream into master

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:

  1. Check out gitlab!49824 (closed) in the Rails app.

  2. Make Workhorse use this branch (replace in Workhorse's go.mod).

  3. Make sure to set Workhorse to use JSON logging: gitlab-development-kit!1738 (merged)

  4. 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}

For gitlab-com/gl-infra/scalability#128.

Edited by Sean McGivern

Merge request reports