add pprof support
This commit is contained in:
@@ -2,6 +2,8 @@ package k8s
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
|
||||
v1 "monitor/pkg/apis/v1"
|
||||
|
||||
@@ -16,6 +18,7 @@ import (
|
||||
|
||||
type Config struct {
|
||||
ctrl.Options
|
||||
PProf bool
|
||||
}
|
||||
|
||||
type Manager struct {
|
||||
@@ -41,6 +44,14 @@ func NewManager(conf Config) (*Manager, error) {
|
||||
return nil, fmt.Errorf("unable to add scheme %w", err)
|
||||
}
|
||||
|
||||
if conf.PProf {
|
||||
mgr.AddMetricsExtraHandler("/debug/pprof/", http.HandlerFunc(pprof.Index))
|
||||
mgr.AddMetricsExtraHandler("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
|
||||
mgr.AddMetricsExtraHandler("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
|
||||
mgr.AddMetricsExtraHandler("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
|
||||
mgr.AddMetricsExtraHandler("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
|
||||
}
|
||||
|
||||
return &Manager{mgr: mgr}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user