-
Notifications
You must be signed in to change notification settings - Fork 314
Expand file tree
/
Copy pathpprof.go
More file actions
30 lines (28 loc) · 1.14 KB
/
pprof.go
File metadata and controls
30 lines (28 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package profiling
import (
"net/http"
"net/http/pprof"
ctrl "sigs.k8s.io/controller-runtime"
)
func AddDebugPprofEndpoints(managerOpts *ctrl.Options) (*ctrl.Options, error) {
pprofEndpoints := map[string]http.HandlerFunc{
"/debug/pprof": http.HandlerFunc(pprof.Index),
"/debug/pprof/allocs": http.HandlerFunc(pprof.Index),
"/debug/pprof/block": http.HandlerFunc(pprof.Index),
"/debug/pprof/cmdline": http.HandlerFunc(pprof.Cmdline),
"/debug/pprof/goroutine": http.HandlerFunc(pprof.Index),
"/debug/pprof/heap": http.HandlerFunc(pprof.Index),
"/debug/pprof/mutex": http.HandlerFunc(pprof.Index),
"/debug/pprof/profile": http.HandlerFunc(pprof.Profile),
"/debug/pprof/symbol": http.HandlerFunc(pprof.Symbol),
"/debug/pprof/threadcreate": http.HandlerFunc(pprof.Index),
"/debug/pprof/trace": http.HandlerFunc(pprof.Trace),
}
if managerOpts.Metrics.ExtraHandlers == nil {
managerOpts.Metrics.ExtraHandlers = make(map[string]http.Handler)
}
for path, handler := range pprofEndpoints {
managerOpts.Metrics.ExtraHandlers[path] = handler
}
return managerOpts, nil
}