Skip to content

Commit

Permalink
adding pprof endpoints to all kit servers
Browse files Browse the repository at this point in the history
  • Loading branch information
jprobinson committed Sep 28, 2017
1 parent 87bdc39 commit 62a4f41
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions server/kit/kitserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"net"
"net/http"
"net/http/pprof"
"os"
"strings"

Expand Down Expand Up @@ -132,6 +133,9 @@ func (s *Server) register(svc Service) {
})
}

// add all pprof endpoints by default to HTTP
registerPprof(s.mux)

gdesc := svc.RPCServiceDesc()
if gdesc == nil {
return
Expand Down Expand Up @@ -218,3 +222,16 @@ func (s *Server) stop() error {
s.exit <- ch
return <-ch
}

func registerPprof(mx Router) {
mx.HandleFunc(http.MethodGet, "/debug/pprof/", pprof.Index)
mx.HandleFunc(http.MethodGet, "/debug/pprof/cmdline", pprof.Cmdline)
mx.HandleFunc(http.MethodGet, "/debug/pprof/profile", pprof.Profile)
mx.HandleFunc(http.MethodGet, "/debug/pprof/symbol", pprof.Symbol)
mx.HandleFunc(http.MethodGet, "/debug/pprof/trace", pprof.Trace)
// Manually add support for paths linked to by index page at /debug/pprof/
mx.Handle(http.MethodGet, "/debug/pprof/goroutine", pprof.Handler("goroutine"))
mx.Handle(http.MethodGet, "/debug/pprof/heap", pprof.Handler("heap"))
mx.Handle(http.MethodGet, "/debug/pprof/threadcreate", pprof.Handler("threadcreate"))
mx.Handle(http.MethodGet, "/debug/pprof/block", pprof.Handler("block"))
}

0 comments on commit 62a4f41

Please sign in to comment.