Skip to content

Commit

Permalink
Add pprof endpoints (jaegertracing#1315)
Browse files Browse the repository at this point in the history
Signed-off-by: Konrad Galuszka <konrad.galuszka.ctr@sabre.com>

Add pprof endpoints (jaegertracing#1315)
  • Loading branch information
Konrad Galuszka committed Mar 27, 2019
1 parent 65a499a commit de60e44
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
14 changes: 14 additions & 0 deletions cmd/flags/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"flag"
"net"
"net/http"
"net/http/pprof"
"strconv"

"github.com/spf13/viper"
Expand Down Expand Up @@ -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))
Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion examples/hotrod/services/frontend/gen_assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions plugin/storage/es/mappings/gen_assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de60e44

Please sign in to comment.