From 7868f0d7ad09cf815440b830829da25a35d8f341 Mon Sep 17 00:00:00 2001 From: Seednode Date: Sun, 14 Jan 2024 09:06:22 -0600 Subject: [PATCH] Register all pprof endpoints --- cmd/profile.go | 34 ++++++++++------------------------ cmd/root.go | 2 +- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/cmd/profile.go b/cmd/profile.go index de7a8ee..b21bea6 100644 --- a/cmd/profile.go +++ b/cmd/profile.go @@ -5,34 +5,20 @@ Copyright © 2023 Seednode package cmd import ( - "fmt" - "net/http" "net/http/pprof" - "strings" - "time" "github.com/julienschmidt/httprouter" ) -func registerProfileHandler(mux *httprouter.Router, verb, path string, handler http.HandlerFunc) { - mux.HandlerFunc(verb, path, handler) - - if Redact && AdminPrefix != "" { - path = strings.ReplaceAll(path, AdminPrefix, "/") - } - - if Handlers { - fmt.Printf("%s | SERVE: Registered handler for %s\n", - time.Now().Format(logDate), - path, - ) - } -} - func registerProfileHandlers(mux *httprouter.Router) { - registerProfileHandler(mux, "GET", Prefix+AdminPrefix+"/debug/pprof/", pprof.Index) - registerProfileHandler(mux, "GET", Prefix+AdminPrefix+"/debug/pprof/cmdline", pprof.Cmdline) - registerProfileHandler(mux, "GET", Prefix+AdminPrefix+"/debug/pprof/profile", pprof.Profile) - registerProfileHandler(mux, "GET", Prefix+AdminPrefix+"/debug/pprof/symbol", pprof.Symbol) - registerProfileHandler(mux, "GET", Prefix+AdminPrefix+"/debug/pprof/trace", pprof.Trace) + mux.Handler("GET", Prefix+AdminPrefix+"/debug/pprof/allocs", pprof.Handler("allocs")) + mux.Handler("GET", Prefix+AdminPrefix+"/debug/pprof/block", pprof.Handler("block")) + mux.Handler("GET", Prefix+AdminPrefix+"/debug/pprof/goroutine", pprof.Handler("goroutine")) + mux.Handler("GET", Prefix+AdminPrefix+"/debug/pprof/heap", pprof.Handler("heap")) + mux.Handler("GET", Prefix+AdminPrefix+"/debug/pprof/mutex", pprof.Handler("mutex")) + mux.Handler("GET", Prefix+AdminPrefix+"/debug/pprof/threadcreate", pprof.Handler("threadcreate")) + mux.HandlerFunc("GET", Prefix+AdminPrefix+"/debug/pprof/cmdline", pprof.Cmdline) + mux.HandlerFunc("GET", Prefix+AdminPrefix+"/debug/pprof/profile", pprof.Profile) + mux.HandlerFunc("GET", Prefix+AdminPrefix+"/debug/pprof/symbol", pprof.Symbol) + mux.HandlerFunc("GET", Prefix+AdminPrefix+"/debug/pprof/trace", pprof.Trace) } diff --git a/cmd/root.go b/cmd/root.go index 4ea0552..3cd8a7b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -18,7 +18,7 @@ import ( const ( AllowedCharacters string = `^[A-z0-9.\-_]+$` - ReleaseVersion string = "5.2.0" + ReleaseVersion string = "5.3.0" ) var (