-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpprof.go
More file actions
23 lines (20 loc) · 949 Bytes
/
pprof.go
File metadata and controls
23 lines (20 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package api
import "net/http/pprof"
// Pprof registers pprof profiling endpoints under the given prefix.
// Default prefix is "/debug/pprof". Routes are hidden from the OpenAPI spec.
func Pprof(r *Router, prefix string) {
if prefix == "" {
prefix = "/debug/pprof"
}
r.mux.HandleFunc("GET "+prefix+"/", pprof.Index)
r.mux.HandleFunc("GET "+prefix+"/cmdline", pprof.Cmdline)
r.mux.HandleFunc("GET "+prefix+"/profile", pprof.Profile)
r.mux.HandleFunc("GET "+prefix+"/symbol", pprof.Symbol)
r.mux.HandleFunc("GET "+prefix+"/trace", pprof.Trace)
r.mux.Handle("GET "+prefix+"/goroutine", pprof.Handler("goroutine"))
r.mux.Handle("GET "+prefix+"/heap", pprof.Handler("heap"))
r.mux.Handle("GET "+prefix+"/allocs", pprof.Handler("allocs"))
r.mux.Handle("GET "+prefix+"/block", pprof.Handler("block"))
r.mux.Handle("GET "+prefix+"/mutex", pprof.Handler("mutex"))
r.mux.Handle("GET "+prefix+"/threadcreate", pprof.Handler("threadcreate"))
}