Fix v2 metrics: Send all ttfb api labels (#20191)

Fix a regression in #19733 where TTFB metrics for all APIs except
GetObject were removed in v2 and v3 metrics. This causes breakage for
existing v2 metrics users. Instead we continue to send TTFB for all APIs
in V2 but only send for GetObject in V3.
This commit is contained in:
Aditya Manthramurthy
2024-07-30 15:28:46 -07:00
committed by GitHub
parent f13c04629b
commit 4c8562bcec
3 changed files with 25 additions and 16 deletions

View File

@@ -27,10 +27,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
)
const (
apiGetObject = "GetObject"
)
// connStats - Network statistics
// Count total input/output transferred bytes during
// the server's life.
@@ -132,7 +128,7 @@ func (bh *bucketHTTPStats) updateHTTPStats(bucket, api string, w *xhttp.Response
return
}
if w != nil && api == apiGetObject {
if w != nil {
// Increment the prometheus http request response histogram with API, Bucket
bucketHTTPRequestsDuration.With(prometheus.Labels{
"api": api,
@@ -437,9 +433,7 @@ func (st *HTTPStats) updateStats(api string, w *xhttp.ResponseRecorder) {
st.totalS3Requests.Inc(api)
// Increment the prometheus http request response histogram with appropriate label
if api == apiGetObject {
httpRequestsDuration.With(prometheus.Labels{"api": api}).Observe(w.TimeToFirstByte.Seconds())
}
httpRequestsDuration.With(prometheus.Labels{"api": api}).Observe(w.TimeToFirstByte.Seconds())
code := w.StatusCode