From fc94ea1cede182090487f50819cfa5d5bce84334 Mon Sep 17 00:00:00 2001 From: Anis Eleuch Date: Fri, 7 Apr 2023 15:51:12 +0100 Subject: [PATCH] trace: Fix func name of requests rejected by max clients (#16977) --- cmd/handler-api.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/handler-api.go b/cmd/handler-api.go index ff3c4b88f..182e9892b 100644 --- a/cmd/handler-api.go +++ b/cmd/handler-api.go @@ -30,6 +30,7 @@ import ( "github.com/minio/minio/internal/config/api" xioutil "github.com/minio/minio/internal/ioutil" "github.com/minio/minio/internal/logger" + "github.com/minio/minio/internal/mcontext" ) type apiConfig struct { @@ -272,6 +273,10 @@ func maxClients(f http.HandlerFunc) http.HandlerFunc { globalHTTPStats.addRequestsInQueue(1) + if tc, ok := r.Context().Value(mcontext.ContextTraceKey).(*mcontext.TraceCtxt); ok { + tc.FuncName = "s3.MaxClients" + } + deadlineTimer := time.NewTimer(deadline) defer deadlineTimer.Stop() @@ -288,6 +293,10 @@ func maxClients(f http.HandlerFunc) http.HandlerFunc { globalHTTPStats.addRequestsInQueue(-1) return case <-r.Context().Done(): + // When the client disconnects before getting the S3 handler + // status code response, set the status code to 499 so this request + // will be properly audited and traced. + w.WriteHeader(499) globalHTTPStats.addRequestsInQueue(-1) return }