From 75648a22a54837560c68f2e864f2ac800ca36b5d Mon Sep 17 00:00:00 2001 From: Branden J Brown Date: Sun, 27 Oct 2024 10:20:41 -0400 Subject: [PATCH] robot: expose pprof api Fixes #29. --- api.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api.go b/api.go index cfdd67e..60ad5b8 100644 --- a/api.go +++ b/api.go @@ -6,6 +6,7 @@ import ( "log/slog" "net" "net/http" + "net/http/pprof" // register handlers "regexp" "time" @@ -54,6 +55,11 @@ func api(ctx context.Context, listen string, mux *http.ServeMux) error { EnableOpenMetrics: true, } mux.Handle("GET /metrics", promhttp.HandlerFor(reg, opts)) + mux.HandleFunc("GET /debug/pprof/", pprof.Index) + mux.HandleFunc("GET /debug/pprof/cmdline", pprof.Cmdline) + mux.HandleFunc("GET /debug/pprof/profile", pprof.Profile) + mux.HandleFunc("GET /debug/pprof/symbol", pprof.Symbol) + mux.HandleFunc("GET /debug/pprof/trace", pprof.Trace) l, err := net.Listen("tcp", listen) if err != nil { return fmt.Errorf("couldn't start API server: %w", err)