frostfs-s3-gw/cmd/gate/app-profiler.go

24 lines
513 B
Go
Raw Normal View History

2020-07-06 09:18:16 +00:00
package main
import (
"net/http/pprof"
"github.com/gorilla/mux"
"github.com/spf13/viper"
2020-07-12 23:00:47 +00:00
"go.uber.org/zap"
2020-07-06 09:18:16 +00:00
)
2020-07-12 23:00:47 +00:00
func attachProfiler(v *viper.Viper, l *zap.Logger, r *mux.Router) {
2020-07-07 11:25:13 +00:00
if !v.GetBool(cfgEnableProfiler) {
2020-07-06 09:18:16 +00:00
return
}
2020-07-12 23:00:47 +00:00
l.Info("enable profiler")
2020-07-06 09:18:16 +00:00
r.HandleFunc("/debug/pprof/", pprof.Index)
r.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
r.HandleFunc("/debug/pprof/profile", pprof.Profile)
r.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
r.HandleFunc("/debug/pprof/trace", pprof.Trace)
}