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
FR: Easy way to add HTTP request/response logging #487
Comments
For the clients that use gRPC, you can try For the non-gRPC clients, like storage, you can use a similar method described in that blog post, though we don't allow you to pass a custom RoundTripper. You'll want this option: Something like this:
|
This is traditional HTTP. Your example worked, though I'm not exactly sure how to tee the Request.Body or Response.Body without interfering with the passthrough. |
You can replace the resp.Body with a TeeReader:
This will print the body to stderr as it's being read by the client. You'll need to do a bit more work since resp.Body is a ReadCloser, but TeeReader is just a Reader. |
@Capstan, if you only care about seeing Google traffic, setting |
I filed golang/go#18733 for maybe adding a GODEBUG=http1debug. |
Pending CL for review: https://go-review.googlesource.com/#/c/36548/ |
I think the code in this issue is sufficient. Closing. |
worked, code snippet with modern version |
Is the above gist still the best way to use your own Transport/RoundTripper? (using googleHTTPTransport.NewTransport instead of googleHTTPTransport.NewClient if not wrapping a Transport but using an existing). |
I looked at https://blog.golang.org/http-tracing, but it doesn't appear to be something I can shoehorn into the clients. Is there an easy recipe I'm missing?
The text was updated successfully, but these errors were encountered: