From 147bf7121fe37b8b28be823a739ec4b31d56e435 Mon Sep 17 00:00:00 2001 From: Bjoern Rabenstein Date: Thu, 27 Nov 2014 16:08:45 +0100 Subject: [PATCH 1/2] Re-add the pprof endpoints. They unintentionally disappeared when switching to julienschmidt/httprouter. --- main.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 0b4fa90d..e58b78f8 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ import ( "log" "net" "net/http" - _ "net/http/pprof" + "net/http/pprof" "os" "os/signal" "runtime" @@ -160,6 +160,9 @@ func main() { r.Handler("GET", "/status", statusHandler) r.Handler("GET", "/", statusHandler) + // Re-enable pprof. + r.GET("/debug/pprof/*pprof", HandlePprof) + log.Printf("Listening on %s.\n", *addr) l, err := net.Listen("tcp", *addr) if err != nil { @@ -177,6 +180,19 @@ func main() { } } +func HandlePprof(w http.ResponseWriter, r *http.Request, p httprouter.Params) { + switch p.ByName("pprof") { + case "/cmdline": + pprof.Cmdline(w, r) + case "/profile": + pprof.Profile(w, r) + case "/symbol": + pprof.Symbol(w, r) + default: + pprof.Index(w, r) + } +} + func interruptHandler(l net.Listener) { notifier := make(chan os.Signal) signal.Notify(notifier, os.Interrupt, syscall.SIGTERM) From fc53b467592093798319013abfde42385292098e Mon Sep 17 00:00:00 2001 From: Bjoern Rabenstein Date: Thu, 27 Nov 2014 16:13:01 +0100 Subject: [PATCH 2/2] Fix capitalization. --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index e58b78f8..882bd944 100644 --- a/main.go +++ b/main.go @@ -161,7 +161,7 @@ func main() { r.Handler("GET", "/", statusHandler) // Re-enable pprof. - r.GET("/debug/pprof/*pprof", HandlePprof) + r.GET("/debug/pprof/*pprof", handlePprof) log.Printf("Listening on %s.\n", *addr) l, err := net.Listen("tcp", *addr) @@ -180,7 +180,7 @@ func main() { } } -func HandlePprof(w http.ResponseWriter, r *http.Request, p httprouter.Params) { +func handlePprof(w http.ResponseWriter, r *http.Request, p httprouter.Params) { switch p.ByName("pprof") { case "/cmdline": pprof.Cmdline(w, r)