@@ -78,8 +78,7 @@ type Client struct {
7878 maxRetries int
7979 retryBackoff func (attempt int ) time.Duration
8080
81- enableMetrics bool
82- metrics * metrics
81+ metrics * metrics
8382
8483 enableDebugLogger bool
8584 debugLogger DebuggingLogger
@@ -125,7 +124,6 @@ func New(cfg Config) *Client {
125124 maxRetries : cfg .MaxRetries ,
126125 retryBackoff : cfg .RetryBackoff ,
127126
128- enableMetrics : cfg .EnableMetrics ,
129127 enableDebugLogger : cfg .EnableDebugLogger ,
130128
131129 transport : cfg .Transport ,
@@ -137,12 +135,10 @@ func New(cfg Config) *Client {
137135 // FIXME(karmi): Type assertion to interface
138136 if pool , ok := client .pool .(* singleConnectionPool ); ok {
139137 client .metrics = & metrics {responses : make (map [int ]int )}
140- pool .enableMetrics = true
141138 pool .metrics = client .metrics
142139 }
143140 if pool , ok := client .pool .(* roundRobinConnectionPool ); ok {
144141 client .metrics = & metrics {responses : make (map [int ]int )}
145- pool .enableMetrics = true
146142 pool .metrics = client .metrics
147143 }
148144 }
@@ -171,7 +167,7 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) {
171167
172168 // Record metrics, when enabled
173169 //
174- if c .enableMetrics {
170+ if c .metrics != nil {
175171 c .metrics .Lock ()
176172 c .metrics .requests ++
177173 c .metrics .Unlock ()
@@ -243,7 +239,7 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) {
243239 if err != nil {
244240 // Record metrics, when enabled
245241 //
246- if c .enableMetrics {
242+ if c .metrics != nil {
247243 c .metrics .Lock ()
248244 c .metrics .failures ++
249245 c .metrics .Unlock ()
@@ -268,7 +264,7 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) {
268264 conn .Unlock ()
269265 }
270266
271- if res != nil && c .enableMetrics {
267+ if res != nil && c .metrics != nil {
272268 c .metrics .Lock ()
273269 c .metrics .responses [res .StatusCode ]++
274270 c .metrics .Unlock ()
0 commit comments