diff --git a/pkg/pmapi/dialer_basic.go b/pkg/pmapi/dialer_basic.go index 8a58c9e5..d3adf908 100644 --- a/pkg/pmapi/dialer_basic.go +++ b/pkg/pmapi/dialer_basic.go @@ -33,9 +33,11 @@ func CreateTransportWithDialer(dialer TLSDialer) *http.Transport { return &http.Transport{ DialTLS: dialer.DialTLS, - Proxy: http.ProxyFromEnvironment, - MaxIdleConns: 100, - IdleConnTimeout: 5 * time.Minute, + Proxy: http.ProxyFromEnvironment, + MaxIdleConns: 100, + MaxIdleConnsPerHost: 100, + IdleConnTimeout: 5 * time.Minute, + ExpectContinueTimeout: 500 * time.Millisecond, // GODT-126: this was initially 10s but logs from users showed a significant number diff --git a/pkg/pmapi/manager.go b/pkg/pmapi/manager.go index c2c9a22f..da33f2ed 100644 --- a/pkg/pmapi/manager.go +++ b/pkg/pmapi/manager.go @@ -43,7 +43,7 @@ func New(cfg Config) Manager { func newManager(cfg Config) *manager { m := &manager{ cfg: cfg, - rc: resty.New(), + rc: resty.New().EnableTrace(), locker: &sync.Mutex{}, } @@ -59,6 +59,7 @@ func newManager(cfg Config) *manager { // wrapped in JSON. If error is returned, `handleRequestFailure` is called, // otherwise `handleRequestSuccess` is called. m.rc.SetError(&Error{}) + m.rc.OnAfterResponse(logConnReuse) m.rc.OnAfterResponse(updateTime) m.rc.OnAfterResponse(m.catchAPIError) m.rc.OnAfterResponse(m.handleRequestSuccess) diff --git a/pkg/pmapi/response.go b/pkg/pmapi/response.go index 1b07ec58..a645a5a8 100644 --- a/pkg/pmapi/response.go +++ b/pkg/pmapi/response.go @@ -82,6 +82,14 @@ func updateTime(_ *resty.Client, res *resty.Response) error { return nil } +func logConnReuse(_ *resty.Client, res *resty.Response) error { + if !res.Request.TraceInfo().IsConnReused { + logrus.WithField("host", res.Request.URL).Trace("Connection was NOT reused") + } + + return nil +} + func catchRetryAfter(_ *resty.Client, res *resty.Response) (time.Duration, error) { if res.StatusCode() == http.StatusTooManyRequests { if after := res.Header().Get("Retry-After"); after != "" {