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 logging for client request and response bodies #135

Merged
merged 5 commits into from
Feb 21, 2022

Conversation

bluekeyes
Copy link
Member

I mostly want this for GraphQL, so that we can inspect the queries made by applications. It seemed easy enough to generalize, so I included the ability to log any client request or response body. Since logging this stuff can be noisy, expensive, or leak sensitive data, it is disabled by default. Individual applications can choose if they want to log all paths or only specific paths.

Putting up a draft PR while I work through the rest of this. Currently, request body logging is implemented but untested. I still need to implement response body logging.

Fixes #49.

@IainSteers
Copy link
Contributor

@bluekeyes I think it may also make sense to add the RateLimit struct to the query structs so that we can retrieve the cost and remaining limit directly on the calls.

https://docs.github.com/en/graphql/overview/resource-limitations#returning-a-calls-rate-limit-status
https://github.com/shurcooL/githubv4/blob/master/example/githubv4dev/main.go#L92-L97

@bluekeyes
Copy link
Member Author

Yeah, I agree rate limit information for GraphQL would be useful. I think that will be a separate change though, since it is pretty involved - need to parse and modify incoming queries then partially decode the responses to extract the information. The only real overlap it has here is that it also needs to modify the bodies of the request and response.

@bluekeyes bluekeyes marked this pull request as ready for review February 18, 2022 18:58
@bluekeyes
Copy link
Member Author

In addition to the unit tests, I ran some quick manual tests using the real GraphQL client and everything seems to work.

@bluekeyes bluekeyes requested a review from a team February 18, 2022 19:24
@bluekeyes bluekeyes merged commit 7365170 into develop Feb 21, 2022
@bluekeyes bluekeyes deleted the bkeyes/body-logging branch February 21, 2022 19:03
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.

Add GraphQL query logging middleware
3 participants