audit: Merge ResponseWriter with RecordAPIStats (#9496)

ResponseWriter & RecordAPIStats has similar role, merge them.

This commit will also fix wrong auditing for STS and Web and others
since they are using ResponseWriter instead of the RecordAPIStats.
This commit is contained in:
Anis Elleuch
2020-04-30 19:27:19 +01:00
committed by GitHub
parent c7470e6e6e
commit 27632ca6ec
5 changed files with 17 additions and 60 deletions
+4 -4
View File
@@ -23,7 +23,7 @@ import (
"sync"
"time"
stats "github.com/minio/minio/cmd/http/stats"
"github.com/minio/minio/cmd/logger"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/atomic"
)
@@ -167,13 +167,13 @@ func (st *HTTPStats) toServerHTTPStats() ServerHTTPStats {
}
// Update statistics from http request and response data
func (st *HTTPStats) updateStats(api string, r *http.Request, w *stats.RecordAPIStats, durationSecs float64) {
func (st *HTTPStats) updateStats(api string, r *http.Request, w *logger.ResponseWriter, durationSecs float64) {
// A successful request has a 2xx response code
successReq := (w.RespStatusCode >= 200 && w.RespStatusCode < 300)
successReq := (w.StatusCode >= 200 && w.StatusCode < 300)
if !strings.HasSuffix(r.URL.Path, prometheusMetricsPath) {
st.totalS3Requests.Inc(api)
if !successReq && w.RespStatusCode != 0 {
if !successReq && w.StatusCode != 0 {
st.totalS3Errors.Inc(api)
}
}