diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2021-07-05 11:29:23 +0300 |
---|---|---|
committer | Vladimir Shushlin <vshushlin@gitlab.com> | 2021-07-05 11:29:23 +0300 |
commit | 59757bc04408388930f2928629c9c12484f3009a (patch) | |
tree | 03a97ac379f5c27fc0867d933caa65627b8b25df | |
parent | 4f7e8aff75dff1a3ba6659bd683f0e60e41e51d4 (diff) | |
parent | 2b1887c217e04f05c885202d73de06f44f315460 (diff) |
Merge branch '588-log-on-tracing-errors' into 'master'
Improve observability of HTTP connections
See merge request gitlab-org/gitlab-pages!515
-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") }, } |