converge/pkg/support/pprof/pprof.go
Erik Brakkee d5a6d70bc4 restructuring test code by introducing a testsupport package
Making it easy 6to start a porof server in tests.
2024-08-20 09:01:46 +02:00

24 lines
760 B
Go

package pprof
import (
"net/http"
"net/http/pprof"
)
func RegisterPprof(mux *http.ServeMux, contextPath string) {
mux.HandleFunc(contextPath+"/", pprof.Index)
mux.HandleFunc(contextPath+"/cmdline", pprof.Cmdline)
mux.HandleFunc(contextPath+"/profile", pprof.Profile)
mux.HandleFunc(contextPath+"/symbol", pprof.Symbol)
mux.HandleFunc(contextPath+"/trace", pprof.Trace)
// Add the allocs handler
mux.Handle("/debug/pprof/allocs", pprof.Handler("allocs"))
// Optional: Add other pprof handlers
mux.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine"))
mux.Handle("/debug/pprof/heap", pprof.Handler("heap"))
mux.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate"))
mux.Handle("/debug/pprof/block", pprof.Handler("block"))
}