mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #31889 from cpuguy83/all_the_pprof
Use generic handler for pprof profile lookups
This commit is contained in:
commit
022552ac87
1 changed files with 9 additions and 4 deletions
|
@ -19,10 +19,15 @@ func profilerSetup(mainRouter *mux.Router) {
|
||||||
r.HandleFunc("/pprof/profile", pprof.Profile)
|
r.HandleFunc("/pprof/profile", pprof.Profile)
|
||||||
r.HandleFunc("/pprof/symbol", pprof.Symbol)
|
r.HandleFunc("/pprof/symbol", pprof.Symbol)
|
||||||
r.HandleFunc("/pprof/trace", pprof.Trace)
|
r.HandleFunc("/pprof/trace", pprof.Trace)
|
||||||
r.HandleFunc("/pprof/block", pprof.Handler("block").ServeHTTP)
|
r.HandleFunc("/pprof/{name}", handlePprof)
|
||||||
r.HandleFunc("/pprof/heap", pprof.Handler("heap").ServeHTTP)
|
}
|
||||||
r.HandleFunc("/pprof/goroutine", pprof.Handler("goroutine").ServeHTTP)
|
|
||||||
r.HandleFunc("/pprof/threadcreate", pprof.Handler("threadcreate").ServeHTTP)
|
func handlePprof(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var name string
|
||||||
|
if vars := mux.Vars(r); vars != nil {
|
||||||
|
name = vars["name"]
|
||||||
|
}
|
||||||
|
pprof.Handler(name).ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replicated from expvar.go as not public.
|
// Replicated from expvar.go as not public.
|
||||||
|
|
Loading…
Add table
Reference in a new issue