From cb3b1a1dcf84b467ec25821efd2faca0cb3af93f Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 22 Jan 2025 06:20:14 -0800 Subject: [PATCH] tsweb: add missing debug pprof endpoints Updates tailscale/corp#26016 Change-Id: I47a5671e881cc092d83c1e992e2271f90afcae7e Signed-off-by: Brad Fitzpatrick --- tsweb/debug.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tsweb/debug.go b/tsweb/debug.go index 6db3f25cf..9e6ce4df4 100644 --- a/tsweb/debug.go +++ b/tsweb/debug.go @@ -52,15 +52,15 @@ func Debugger(mux *http.ServeMux) *DebugHandler { ret.KV("Version", version.Long()) ret.Handle("vars", "Metrics (Go)", expvar.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)) - // the CPU profile handler is special because it responds - // streamily, unlike every other pprof handler. This means it's - // 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. + // But register the other ones from net/http/pprof directly: + ret.HandleSilent("pprof/cmdline", http.HandlerFunc(pprof.Cmdline)) 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=2", "Goroutines (full)") ret.Handle("gc", "force GC", http.HandlerFunc(gcHandler))