From ec46a34f338ae40d2840c8569b26b02f8c8fbb22 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Tue, 4 Oct 2022 13:20:01 +0500 Subject: [PATCH] avoid increasing the coordinates of metric labels (#3785) --- weed/s3api/stats.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/weed/s3api/stats.go b/weed/s3api/stats.go index cfdb3fb69..2b36478ad 100644 --- a/weed/s3api/stats.go +++ b/weed/s3api/stats.go @@ -33,6 +33,12 @@ func track(f http.HandlerFunc, action string) http.HandlerFunc { recorder := NewStatusResponseWriter(w) start := time.Now() f(recorder, r) + if recorder.Status == http.StatusForbidden { + if m, _ := stats_collect.S3RequestCounter.GetMetricWithLabelValues( + action, strconv.Itoa(http.StatusOK), bucket); m == nil { + bucket = "" + } + } stats_collect.S3RequestHistogram.WithLabelValues(action, bucket).Observe(time.Since(start).Seconds()) stats_collect.S3RequestCounter.WithLabelValues(action, strconv.Itoa(recorder.Status), bucket).Inc() }