fix: gateway_s3_bytes_sent metric for all API methods (#9242)

Co-authored-by: Harshavardhana <harsha@minio.io>
This commit is contained in:
poornas
2020-04-01 12:52:31 -07:00
committed by GitHub
parent 95e89f1712
commit 336460f67e
4 changed files with 29 additions and 4 deletions
+3 -2
View File
@@ -432,7 +432,7 @@ type MetricsTransport struct {
// RoundTrip implements the RoundTrip method for MetricsTransport
func (m MetricsTransport) RoundTrip(r *http.Request) (*http.Response, error) {
metered := shouldMeterRequest(r)
if metered && (r.Method == http.MethodGet || r.Method == http.MethodHead) {
if metered && (r.Method == http.MethodPost || r.Method == http.MethodPut) {
m.Metrics.IncRequests(r.Method)
if r.ContentLength > 0 {
m.Metrics.IncBytesSent(uint64(r.ContentLength))
@@ -444,7 +444,8 @@ func (m MetricsTransport) RoundTrip(r *http.Request) (*http.Response, error) {
return nil, err
}
if metered && (r.Method == http.MethodGet || r.Method == http.MethodHead) {
if r.ContentLength > 0 {
m.Metrics.IncRequests(r.Method)
if resp.ContentLength > 0 {
m.Metrics.IncBytesReceived(uint64(resp.ContentLength))
}
}