enhance: enable profile and block profiling (#34642)

fix #34641

Signed-off-by: xiaofanluan <xiaofan.luan@zilliz.com>
This commit is contained in:
Xiaofan 2024-07-19 18:43:41 +08:00 committed by GitHub
parent a11714913b
commit 7eaef09ba5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,6 +20,7 @@ import (
"fmt"
"net/http"
"os"
"runtime"
"strconv"
"time"
@ -151,6 +152,10 @@ func ServeHTTP() {
bindAddr := getHTTPAddr()
log.Info("management listen", zap.String("addr", bindAddr))
server = &http.Server{Handler: metricsServer, Addr: bindAddr, ReadTimeout: 10 * time.Second}
// enable mutex && block profile, sampling rate 10%
runtime.SetMutexProfileFraction(10)
runtime.SetBlockProfileRate(10)
if err := server.ListenAndServe(); err != nil {
log.Error("handle metrics failed", zap.Error(err))
}