From de60e4441ea9a028653ffe5e325c323848c5f51d Mon Sep 17 00:00:00 2001 From: Konrad Galuszka Date: Fri, 22 Feb 2019 08:48:00 -0600 Subject: [PATCH] Add pprof endpoints (#1315) Signed-off-by: Konrad Galuszka Add pprof endpoints (#1315) --- cmd/flags/admin.go | 14 ++++++++++++++ examples/hotrod/services/frontend/gen_assets.go | 2 +- plugin/storage/es/mappings/gen_assets.go | 6 +++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd/flags/admin.go b/cmd/flags/admin.go index 51718481e41..bf34109558e 100644 --- a/cmd/flags/admin.go +++ b/cmd/flags/admin.go @@ -19,6 +19,7 @@ import ( "flag" "net" "net/http" + "net/http/pprof" "strconv" "github.com/spf13/viper" @@ -107,6 +108,7 @@ func (s *AdminServer) serveWithListener(l net.Listener) { s.logger.Info("Mounting health check on admin server", zap.String("route", "/")) s.mux.Handle("/", s.hc.Handler()) version.RegisterHandler(s.mux, s.logger) + s.registerPprofHandlers() recoveryHandler := recoveryhandler.NewRecoveryHandler(s.logger, true) s.server = &http.Server{Handler: recoveryHandler(s.mux)} s.logger.Info("Starting admin HTTP server", zap.Int("http-port", s.adminPort)) @@ -118,6 +120,18 @@ func (s *AdminServer) serveWithListener(l net.Listener) { }() } +func (s *AdminServer) registerPprofHandlers() { + s.mux.HandleFunc("/debug/pprof/", pprof.Index) + s.mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) + s.mux.HandleFunc("/debug/pprof/profile", pprof.Profile) + s.mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) + s.mux.HandleFunc("/debug/pprof/trace", pprof.Trace) + s.mux.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine")) + s.mux.Handle("/debug/pprof/heap", pprof.Handler("heap")) + s.mux.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate")) + s.mux.Handle("/debug/pprof/block", pprof.Handler("block")) +} + // Close stops the HTTP server func (s *AdminServer) Close() error { return s.server.Shutdown(context.Background()) diff --git a/examples/hotrod/services/frontend/gen_assets.go b/examples/hotrod/services/frontend/gen_assets.go index f3e944df1dc..f7510c1ec1d 100644 --- a/examples/hotrod/services/frontend/gen_assets.go +++ b/examples/hotrod/services/frontend/gen_assets.go @@ -213,7 +213,7 @@ var _escData = map[string]*_escFile{ name: "index.html", local: "examples/hotrod/services/frontend/web_assets/index.html", size: 3384, - modtime: 1491239234, + modtime: 1551364059, compressed: ` H4sIAAAAAAAC/9RX/1PbOBb/PX/FG23v7FywnRAoNMS54UiX0r0uvUC709vpD7L0YivYkivJgSzD/34j 2wkJlJv9cZsZQHrfP++LXhhntsgnHYBxgZYCy6g2aGNycXUZHB8fvgkG5JEraYExWQq8LZW2BJiSFqWN diff --git a/plugin/storage/es/mappings/gen_assets.go b/plugin/storage/es/mappings/gen_assets.go index 708037597cc..3a6d3af86b5 100644 --- a/plugin/storage/es/mappings/gen_assets.go +++ b/plugin/storage/es/mappings/gen_assets.go @@ -213,7 +213,7 @@ var _escData = map[string]*_escFile{ name: ".nocover", local: "plugin/storage/es/mappings/.nocover", size: 43, - modtime: 1549990175, + modtime: 1551364059, compressed: ` H4sIAAAAAAAC/youSSzJzFYoSEzOTkxPVcjILy4pVkgsLcnXTU/NSy1KLElNUUjLzEkt1uMCBAAA//8y IKK1KwAAAA== @@ -224,7 +224,7 @@ IKK1KwAAAA== name: "jaeger-service.json", local: "plugin/storage/es/mappings/jaeger-service.json", size: 1060, - modtime: 1549990175, + modtime: 1551364059, compressed: ` H4sIAAAAAAAC/8yTT2/UMBDF7/kU1ojTamshpHLwrUARSFDQVpwQGs3Gs1mD7RjbKayqfHfk4pKkW+2J Q3PIn/F78/xz7NtGCMjsgqXMoASsvhN3HM8SxxvT8tkK1kWSOGfjuwSqOIQA4zX/ln5wW47Y7zDtKeoE @@ -240,7 +240,7 @@ TmGdQJrhQAmkbHr//7o382e5j83Y/AkAAP//qd2MzCQEAAA= name: "jaeger-span.json", local: "plugin/storage/es/mappings/jaeger-span.json", size: 3776, - modtime: 1549990175, + modtime: 1551364059, compressed: ` H4sIAAAAAAAC/+xWUW/TMBB+z6+ITjxNW4SQxkPeBhtiEhtoG08IWdfkknpzbGNfB9XU/47SZLRZnHRI DUKCPayN7e+7+3x3X/MQxTEwVVYhE6QxHNwileSOvEV9dACH9b4nZqlLD2l9PI5B6px+JHpRzcgJUwg/