tracing: NumSubscribers() to use atomic instead of mutex (#11219)

globalSubscribers.NumSubscribers() is heavily used in S3 requests and it
uses mutex, use atomic.Load instead since it is faster

Co-authored-by: Anis Elleuch <anis@min.io>
This commit is contained in:
Anis Elleuch
2021-01-04 18:40:30 +01:00
committed by GitHub
parent dfd99b6d8f
commit 153d4be032
6 changed files with 13 additions and 16 deletions

View File

@@ -348,7 +348,7 @@ func extractPostPolicyFormValues(ctx context.Context, form *multipart.Form) (fil
// Log headers and body.
func httpTraceAll(f http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if !globalHTTPTrace.HasSubscribers() {
if globalHTTPTrace.NumSubscribers() == 0 {
f.ServeHTTP(w, r)
return
}
@@ -360,7 +360,7 @@ func httpTraceAll(f http.HandlerFunc) http.HandlerFunc {
// Log only the headers.
func httpTraceHdrs(f http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if !globalHTTPTrace.HasSubscribers() {
if globalHTTPTrace.NumSubscribers() == 0 {
f.ServeHTTP(w, r)
return
}