Skip to content

Commit

Permalink
Merge pull request #13 from prometheus/bug/re-add-pprof-endpoints
Browse files Browse the repository at this point in the history
Re-add the pprof endpoints.
  • Loading branch information
beorn7 committed Nov 27, 2014
2 parents ff20077 + fc53b46 commit db26a00
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"log"
"net"
"net/http"
_ "net/http/pprof"
"net/http/pprof"
"os"
"os/signal"
"runtime"
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit db26a00

Please sign in to comment.