@ -434,7 +434,9 @@ func (m MetricsTransport) RoundTrip(r *http.Request) (*http.Response, error) {
metered := shouldMeterRequest ( r )
metered := shouldMeterRequest ( r )
if metered && ( r . Method == http . MethodGet || r . Method == http . MethodHead ) {
if metered && ( r . Method == http . MethodGet || r . Method == http . MethodHead ) {
m . Metrics . IncRequests ( r . Method )
m . Metrics . IncRequests ( r . Method )
m . Metrics . IncBytesSent ( r . ContentLength )
if r . ContentLength > 0 {
m . Metrics . IncBytesSent ( uint64 ( r . ContentLength ) )
}
}
}
// Make the request to the server.
// Make the request to the server.
resp , err := m . Transport . RoundTrip ( r )
resp , err := m . Transport . RoundTrip ( r )
@ -442,7 +444,9 @@ func (m MetricsTransport) RoundTrip(r *http.Request) (*http.Response, error) {
return nil , err
return nil , err
}
}
if metered && ( r . Method == http . MethodGet || r . Method == http . MethodHead ) {
if metered && ( r . Method == http . MethodGet || r . Method == http . MethodHead ) {
m . Metrics . IncBytesReceived ( resp . ContentLength )
if r . ContentLength > 0 {
m . Metrics . IncBytesReceived ( uint64 ( resp . ContentLength ) )
}
}
}
return resp , nil
return resp , nil
}
}