httpclient: Create trace logging for outgoing HTTP requests

Sometimes HTTP requests are buried inside third-party libraries where we
can't otherwise access their request method/URL, so this ensures we'll
always have at least a record of the fact that a request happened, even if
there's no other logging for why it did.

We only include the method and URL here under the assumption that
secret keys and other particularly sensitive information will not appear
there, in line with usual best-practices.
This commit is contained in:
Martin Atkins 2019-07-12 16:54:31 -07:00
parent e1590d0a70
commit 0f2c4b3b68
1 changed files with 1 additions and 0 deletions

View File

@ -36,5 +36,6 @@ func (rt *userAgentRoundTripper) RoundTrip(req *http.Request) (*http.Response, e
if _, ok := req.Header["User-Agent"]; !ok {
req.Header.Set("User-Agent", rt.userAgent)
}
log.Printf("[TRACE] HTTP client %s request to %s", req.Method, req.URL.String())
return rt.inner.RoundTrip(req)
}