Skip to content
This repository was archived by the owner on Feb 1, 2021. It is now read-only.

http trace add ConnectStart #246

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ func newRequest(ctx context.Context, method, reqUrl string, headers http.Header,
}
if DebugMode {
trace := &httptrace.ClientTrace{
// 如果 ConnectStart GotConn 都没有显示,很可能是 DNS 失败
ConnectStart: func(network, addr string) {
log.Debug(fmt.Sprintf("ConnectStart Network: %s, Remote ip:%s, URL: %s", network, addr, req.URL))
},
GotConn: func(connInfo httptrace.GotConnInfo) {
remoteAddr := connInfo.Conn.RemoteAddr()
log.Debug(fmt.Sprintf("Network: %s, Remote ip:%s, URL: %s", remoteAddr.Network(), remoteAddr.String(), req.URL))
log.Debug(fmt.Sprintf("GotConn Network: %s, Remote ip:%s, URL: %s", remoteAddr.Network(), remoteAddr.String(), req.URL))
},
}
req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
Expand Down