mirror of
https://github.com/goharbor/harbor
synced 2025-04-24 23:28:12 +00:00
Fix instrumenting handler nest issue
remove nested handler for instrumenting Signed-off-by: DQ <dengq@vmware.com>
This commit is contained in:
parent
f24d349ede
commit
72ff33f80b
@ -17,9 +17,7 @@ func instrumentHandler(next http.Handler) http.Handler {
|
||||
metric.TotalInFlightGauge.WithLabelValues(url).Inc()
|
||||
defer metric.TotalInFlightGauge.WithLabelValues(url).Dec()
|
||||
rc := lib.NewResponseRecorder(w)
|
||||
|
||||
next.ServeHTTP(rc, r)
|
||||
|
||||
metric.TotalReqDurSummary.WithLabelValues(r.Method, url).Observe(time.Since(now).Seconds())
|
||||
metric.TotalReqCnt.WithLabelValues(r.Method, strconv.Itoa(rc.StatusCode), url).Inc()
|
||||
})
|
||||
@ -28,12 +26,7 @@ func instrumentHandler(next http.Handler) http.Handler {
|
||||
// Middleware returns a middleware for handling requests
|
||||
func Middleware() func(http.Handler) http.Handler {
|
||||
if config.Metric().Enabled {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||
next = instrumentHandler(next)
|
||||
next.ServeHTTP(rw, req)
|
||||
})
|
||||
}
|
||||
return instrumentHandler
|
||||
}
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user