Skip to content

Commit

Permalink
feat(hatchery): pprof (#3396)
Browse files Browse the repository at this point in the history
Signed-off-by: Yvonnick Esnault <[email protected]>
  • Loading branch information
yesnault authored Oct 3, 2018
1 parent c379464 commit 4d0b6c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion engine/api/api_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,5 +428,5 @@ func (api *API) InitRouter() {
r.Handle("/services/{type}", r.GET(api.getExternalServiceHandler, NeedWorker()))

//Not Found handler
r.Mux.NotFoundHandler = http.HandlerFunc(notFoundHandler)
r.Mux.NotFoundHandler = http.HandlerFunc(NotFoundHandler)
}
2 changes: 1 addition & 1 deletion engine/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ func EnableTracing() HandlerConfigParam {
return f
}

func notFoundHandler(w http.ResponseWriter, req *http.Request) {
func NotFoundHandler(w http.ResponseWriter, req *http.Request) {
start := time.Now()
defer func() {
end := time.Now()
Expand Down
11 changes: 11 additions & 0 deletions engine/hatchery/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"io/ioutil"
"net/http"
"net/http/pprof"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -185,6 +186,16 @@ func (c *Common) initRouter(ctx context.Context, h hatchery.Interface) {
r.Handle("/mon/metrics", r.GET(observability.StatsHandler, api.Auth(false)))
r.Handle("/mon/errors", r.GET(c.getPanicDumpListHandler, api.Auth(false)))
r.Handle("/mon/errors/{id}", r.GET(c.getPanicDumpHandler, api.Auth(false)))

r.Mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
r.Mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
r.Mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
r.Mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
// need 2 routes for index, one for index page, another with {action}
r.Mux.HandleFunc("/debug/pprof/{action}", pprof.Index)
r.Mux.HandleFunc("/debug/pprof/", pprof.Index)

r.Mux.NotFoundHandler = http.HandlerFunc(api.NotFoundHandler)
}

func (c *Common) getPanicDumpListHandler() service.Handler {
Expand Down

0 comments on commit 4d0b6c3

Please sign in to comment.