Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pprof and create admin endpoint #1375

Merged
merged 3 commits into from
Apr 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.