Skip to content

Commit

Permalink
robot: expose pprof api
Browse files Browse the repository at this point in the history
Fixes #29.
  • Loading branch information
zephyrtronium committed Oct 27, 2024
1 parent 87610af commit 75648a2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log/slog"
"net"
"net/http"
"net/http/pprof" // register handlers
"regexp"
"time"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 75648a2

Please sign in to comment.