Add time to first byte metric for s3 (#4768)

* Add time to first byte metric for s3

* Change second to millisecond
This commit is contained in:
SmsS4
2023-08-21 11:12:39 +03:30
committed by GitHub
parent 3650e5adda
commit f61490966f
3 changed files with 17 additions and 1 deletions

View File

@@ -43,3 +43,8 @@ func track(f http.HandlerFunc, action string) http.HandlerFunc {
stats_collect.S3RequestCounter.WithLabelValues(action, strconv.Itoa(recorder.Status), bucket).Inc()
}
}
func TimeToFirstByte(action string, start time.Time, r *http.Request) {
bucket, _ := s3_constants.GetBucketAndObject(r)
stats_collect.S3TimeToFirstByteHistogram.WithLabelValues(action, bucket).Observe(float64(time.Since(start).Milliseconds()))
}