diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-07-05 07:06:54 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-07-05 07:06:54 +0300 |
commit | 2b1887c217e04f05c885202d73de06f44f315460 (patch) | |
tree | 03a97ac379f5c27fc0867d933caa65627b8b25df /internal/httptransport | |
parent | 4f7e8aff75dff1a3ba6659bd683f0e60e41e51d4 (diff) |
Improve observability of HTTP connections
Changelog: other
Diffstat (limited to 'internal/httptransport')
-rw-r--r-- | internal/httptransport/trace.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/internal/httptransport/trace.go b/internal/httptransport/trace.go index 9ece5fc4..273321e4 100644 --- a/internal/httptransport/trace.go +++ b/internal/httptransport/trace.go @@ -50,10 +50,16 @@ func (mrt *meteredRoundTripper) newTracer(start time.Time) *httptrace. ConnectDone: func(net string, addr string, err error) { mrt.httpTraceObserve("httptrace.ClientTrace.ConnectDone", start) - log.WithFields(log.Fields{ + l := log.WithFields(log.Fields{ "network": net, "address": addr, - }).WithError(err).Traceln("httptrace.ClientTrace.ConnectDone") + }) + + if err != nil { + l.WithError(err).Error("httptrace.ClientTrace.ConnectDone") + } + + l.Traceln("httptrace.ClientTrace.ConnectDone") }, TLSHandshakeStart: func() { mrt.httpTraceObserve("httptrace.ClientTrace.TLSHandshakeStart", start) @@ -61,10 +67,16 @@ func (mrt *meteredRoundTripper) newTracer(start time.Time) *httptrace. TLSHandshakeDone: func(connState tls.ConnectionState, err error) { mrt.httpTraceObserve("httptrace.ClientTrace.TLSHandshakeDone", start) - log.WithFields(log.Fields{ + l := log.WithFields(log.Fields{ "version": connState.Version, "connection_resumed": connState.DidResume, - }).WithError(err).Traceln("httptrace.ClientTrace.TLSHandshakeDone") + }) + + if err != nil { + l.WithError(err).Error("httptrace.ClientTrace.TLSHandshakeDone") + } + + l.Traceln("httptrace.ClientTrace.TLSHandshakeDone") }, } |