8000 feat(hatchery): pprof (#3396) · ovh/cds@4d0b6c3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 4d0b6c3

Browse files
authored
feat(hatchery): pprof (#3396)
Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
1 parent c379464 commit 4d0b6c3

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

engine/api/api_routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,5 +428,5 @@ func (api *API) InitRouter() {
428428
r.Handle("/services/{type}", r.GET(api.getExternalServiceHandler, NeedWorker()))
429429

430430
//Not Found handler
431-
r.Mux.NotFoundHandler = http.HandlerFunc(notFoundHandler)
431+
r.Mux.NotFoundHandler = http.HandlerFunc(NotFoundHandler)
432432
}

engine/api/router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ func EnableTracing() HandlerConfigParam {
488488
return f
489489
}
490490

491-
func notFoundHandler(w http.ResponseWriter, req *http.Request) {
491+
func NotFoundHandler(w http.ResponseWriter, req *http.Request) {
492492
start := time.Now()
493493
defer func() {
494494
end := time.Now()

engine/hatchery/serve.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"io/ioutil"
99
"net/http"
10+
"net/http/pprof"
1011
"os"
1112
"path/filepath"
1213
"time"
@@ -185,6 +186,16 @@ func (c *Common) initRouter(ctx context.Context, h hatchery.Interface) {
185186
r.Handle("/mon/metrics", r.GET(observability.StatsHandler, api.Auth(false)))
186187
r.Handle("/mon/errors", r.GET(c.getPanicDumpListHandler, api.Auth(false)))
187188
r.Handle("/mon/errors/{id}", r.GET(c.getPanicDumpHandler, api.Auth(false)))
189+
190+
r.Mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
191+
r.Mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
192+
r.Mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
193+
r.Mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
194+
// need 2 routes for index, one for index page, another with {action}
195+
r.Mux.HandleFunc("/debug/pprof/{action}", pprof.Index)
196+
r.Mux.HandleFunc("/debug/pprof/", pprof.Index)
197+
198+
r.Mux.NotFoundHandler = http.HandlerFunc(api.NotFoundHandler)
188199
}
189200

190201
func (c *Common) getPanicDumpListHandler() service.Handler {

0 commit comments

Comments
 (0)
0