forked from TrueCloudLab/frostfs-node
Add Inner Ring code
This commit is contained in:
parent
dadfd90dcd
commit
b7b5079934
400 changed files with 11420 additions and 8690 deletions
44
pkg/util/profiler/pprof.go
Normal file
44
pkg/util/profiler/pprof.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package profiler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"expvar"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Profiler is an interface of profiler.
|
||||
type Profiler interface {
|
||||
Start(ctx context.Context)
|
||||
Stop()
|
||||
}
|
||||
|
||||
const profilerKey = "pprof"
|
||||
|
||||
// NewProfiler is a profiler's constructor.
|
||||
func NewProfiler(l *zap.Logger, v *viper.Viper) Profiler {
|
||||
if !v.GetBool(profilerKey + ".enabled") {
|
||||
l.Debug("pprof server disabled")
|
||||
return nil
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.Handle("/debug/vars", expvar.Handler())
|
||||
|
||||
mux.HandleFunc("/debug/pprof/", pprof.Index)
|
||||
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
||||
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
||||
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
||||
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||
|
||||
return newHTTPServer(httpParams{
|
||||
Key: profilerKey,
|
||||
Viper: v,
|
||||
Logger: l,
|
||||
Handler: mux,
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue