Add user_guid to request logs #3087
Merged
+85
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A short explanation of the proposed change:
Add the field
user_guid
to request logs inCloudFoundry::Middleware::SecurityContextSetter
.An explanation of the use cases your change solves
Currently the only Cloud Controller logs which include
user_guid
as a field arenginx_access
logs. The values of user guids appear incidentally in the log message itself in a handful of cases (about 0.6% of all logs), generally in SQL statements and errors.The Steno logging library always adds eight fields to request logs (including the log message itself), and at present our middleware adds another three: the
request_guid
,b3_trace_id
andb3_span_id
. The latter two are added by CloudFoundry::Middleware::Zipkin, and the former by CloudFoundry::Middleware::VcapRequestId.We think having access to the
user_guid
in all request logs could make it easier to debug certain kinds of issues. If you're interested in a single request, it's already possible (though a bit laborious) to trace your way back from some downstream request log to the nginx log that gives you theuser_guid
. But if you're seeing a pattern across many requests, there's currently no convenient way to know if they're all coming from one particular user. If every log carried theuser_guid
, it'd be pretty easy with tools like Kibana to do that sort of analysis.Links to any other associated PRs
I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
main
branchI have run all the unit tests using
bundle exec rake
I have run CF Acceptance Tests