diff --git a/debug/debug.go b/debug/debug.go index a768c961..803633d0 100644 --- a/debug/debug.go +++ b/debug/debug.go @@ -95,6 +95,13 @@ func MountPprofHandlers(mux Muxer, opts ...PprofOption) { mux.HandleFunc(o.prefix+"profile", pprof.Profile) mux.HandleFunc(o.prefix+"symbol", pprof.Symbol) mux.HandleFunc(o.prefix+"trace", pprof.Trace) + + mux.Handle(o.prefix+"goroutine", pprof.Handler("goroutine")) + mux.Handle(o.prefix+"threadcreate", pprof.Handler("threadcreate")) + mux.Handle(o.prefix+"mutex", pprof.Handler("mutex")) + mux.Handle(o.prefix+"heap", pprof.Handler("heap")) + mux.Handle(o.prefix+"block", pprof.Handler("block")) + mux.Handle(o.prefix+"allocs", pprof.Handler("allocs")) } // LogPayloads returns a Goa endpoint middleware that logs request payloads and diff --git a/debug/debug_test.go b/debug/debug_test.go index 49570e46..a82ebcba 100644 --- a/debug/debug_test.go +++ b/debug/debug_test.go @@ -12,6 +12,7 @@ import ( "goa.design/clue/internal/testsvc" "goa.design/clue/internal/testsvc/gen/test" "goa.design/clue/log" + goahttp "goa.design/goa/v3/http" ) func TestMountDebugLogEnabler(t *testing.T) { @@ -76,10 +77,10 @@ func TestMountDebugLogEnabler(t *testing.T) { } func TestMountPprofHandlers(t *testing.T) { - mux := http.NewServeMux() - MountPprofHandlers(mux) - MountPprofHandlers(mux, WithPrefix("test")) - var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + mux := goahttp.NewMuxer() + MountPprofHandlers(Adapt(mux)) + MountPprofHandlers(Adapt(mux), WithPrefix("test")) + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { w.WriteHeader(http.StatusNotFound) return @@ -87,7 +88,7 @@ func TestMountPprofHandlers(t *testing.T) { w.WriteHeader(http.StatusOK) w.Write([]byte("OK")) // nolint: errcheck }) - mux.Handle("/", handler) + mux.Handle(http.MethodGet, "/", handler) ts := httptest.NewServer(mux) defer ts.Close()