Description
I keep hearing requests for getting more analytics and timing information out of net/http.Transport.
I will reference some requests and use cases and similar bugs here.
- https://groups.google.com/forum/#!searchin/golang-nuts/Responding$20IP$20address$20for$20http$20requests/golang-nuts/Tnuy57IkJ2s/vHnOJhp9frQJ is about "way to establish what IP address a golang http client tried to establish an http connection to when making a request, in order to add extra information to logs (particularly for debugging CDNs with global edge servers and geoDNS etc). Obviously this information is needed for both the errors and completed responses"
-
12503 is about getting timing information out of the net.Dialer's resolver, which the http.Transport uses as well, and internal teams at Google have requested (specifically for use via the http.Transport)
- I closed net/http: add Request.LocalAddr #6732 (net/http: add Request.LocalAddr) without action, but I think it can be addressed by a more general solution here, perhaps.
Feel free to add things I'm missing.
I have a rough design idea to add an optional func field to http.Transport to let people return an opaque-to-net/http interface{}
at the beginning of a request and get it passed back to them at various stages of the request, so people can do their own timing/logging. I want to be careful not to give people too many hooks to modify internals and constrain the transport implementation in the future (which includes the HTTP/2 implementation), so I'll probably start pretty conservatively, but with an eye towards adding more steps in the future as needed.
But let's gather requirements before discussing implementation too much.