Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user_guid to request logs #3087

Merged
merged 1 commit into from
Dec 15, 2022

Conversation

will-gant
Copy link
Contributor

@will-gant will-gant commented Dec 2, 2022

A short explanation of the proposed change:

Add the field user_guid to request logs in CloudFoundry::Middleware::SecurityContextSetter.

An explanation of the use cases your change solves

Currently the only Cloud Controller logs which include user_guid as a field are nginx_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 and b3_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 the user_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 the user_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 branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@will-gant will-gant force-pushed the log-user-guid branch 7 times, most recently from 2ad0f68 to 5843fe5 Compare December 8, 2022 09:22
@will-gant will-gant marked this pull request as ready for review December 15, 2022 06:47
@FloThinksPi FloThinksPi merged commit 8e12701 into cloudfoundry:main Dec 15, 2022
@FloThinksPi FloThinksPi deleted the log-user-guid branch December 15, 2022 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants