tsweb: add missing debug pprof endpoints

Updates tailscale/corp#26016

Change-Id: I47a5671e881cc092d83c1e992e2271f90afcae7e
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2025-01-22 06:20:14 -08:00 committed by Brad Fitzpatrick
parent 042ed6bf69
commit cb3b1a1dcf

View File

@ -52,15 +52,15 @@ func Debugger(mux *http.ServeMux) *DebugHandler {
ret.KV("Version", version.Long()) ret.KV("Version", version.Long())
ret.Handle("vars", "Metrics (Go)", expvar.Handler()) ret.Handle("vars", "Metrics (Go)", expvar.Handler())
ret.Handle("varz", "Metrics (Prometheus)", http.HandlerFunc(promvarz.Handler)) ret.Handle("varz", "Metrics (Prometheus)", http.HandlerFunc(promvarz.Handler))
// pprof.Index serves everything that runtime/pprof.Lookup finds:
// goroutine, threadcreate, heap, allocs, block, mutex
ret.Handle("pprof/", "pprof (index)", http.HandlerFunc(pprof.Index)) ret.Handle("pprof/", "pprof (index)", http.HandlerFunc(pprof.Index))
// the CPU profile handler is special because it responds // But register the other ones from net/http/pprof directly:
// streamily, unlike every other pprof handler. This means it's ret.HandleSilent("pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
// not made available through pprof.Index the way all the other
// pprof types are, you have to register the CPU profile handler
// separately. Use HandleSilent for that to not pollute the human
// debug list with a link that produces streaming line noise if
// you click it.
ret.HandleSilent("pprof/profile", http.HandlerFunc(pprof.Profile)) ret.HandleSilent("pprof/profile", http.HandlerFunc(pprof.Profile))
ret.HandleSilent("pprof/symbol", http.HandlerFunc(pprof.Symbol))
ret.HandleSilent("pprof/trace", http.HandlerFunc(pprof.Trace))
ret.URL("/debug/pprof/goroutine?debug=1", "Goroutines (collapsed)") ret.URL("/debug/pprof/goroutine?debug=1", "Goroutines (collapsed)")
ret.URL("/debug/pprof/goroutine?debug=2", "Goroutines (full)") ret.URL("/debug/pprof/goroutine?debug=2", "Goroutines (full)")
ret.Handle("gc", "force GC", http.HandlerFunc(gcHandler)) ret.Handle("gc", "force GC", http.HandlerFunc(gcHandler))