NewDebugClientTrace returns a Go http trace client predefined to write DNS and connection information to the log. This is used via the --http-trace flag on push and pull operations in ctr.
(ctx context.Context)
| 76 | // NewDebugClientTrace returns a Go http trace client predefined to write DNS and connection |
| 77 | // information to the log. This is used via the --http-trace flag on push and pull operations in ctr. |
| 78 | func NewDebugClientTrace(ctx context.Context) *httptrace.ClientTrace { |
| 79 | return &httptrace.ClientTrace{ |
| 80 | DNSStart: func(dnsInfo httptrace.DNSStartInfo) { |
| 81 | log.G(ctx).WithField("host", dnsInfo.Host).Debugf("DNS lookup") |
| 82 | }, |
| 83 | DNSDone: func(dnsInfo httptrace.DNSDoneInfo) { |
| 84 | if dnsInfo.Err != nil { |
| 85 | log.G(ctx).WithField("lookup_err", dnsInfo.Err).Debugf("DNS lookup error") |
| 86 | } else { |
| 87 | log.G(ctx).WithField("result", dnsInfo.Addrs[0].String()).WithField("coalesced", dnsInfo.Coalesced).Debugf("DNS lookup complete") |
| 88 | } |
| 89 | }, |
| 90 | GotConn: func(connInfo httptrace.GotConnInfo) { |
| 91 | remoteAddr := "<nil>" |
| 92 | if addr := connInfo.Conn.RemoteAddr(); addr != nil { |
| 93 | remoteAddr = addr.String() |
| 94 | } |
| 95 | |
| 96 | log.G(ctx).WithField("reused", connInfo.Reused).WithField("remote_addr", remoteAddr).Debugf("Connection successful") |
| 97 | }, |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | type traceTransport struct { |
| 102 | tracer *httptrace.ClientTrace |
no test coverage detected
searching dependent graphs…