diff --git a/cmd/anubis/main.go b/cmd/anubis/main.go index c0b2a9d3..fad6c9dd 100644 --- a/cmd/anubis/main.go +++ b/cmd/anubis/main.go @@ -17,6 +17,7 @@ import ( "net" "net/http" "net/http/httputil" + "net/http/pprof" "net/url" "os" "os/signal" @@ -522,6 +523,11 @@ func metricsServer(ctx context.Context, lg slog.Logger, done func()) { defer done() mux := http.NewServeMux() + 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) mux.Handle("/metrics", promhttp.Handler()) mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { st, ok := internal.GetHealth("anubis") diff --git a/docs/docs/CHANGELOG.md b/docs/docs/CHANGELOG.md index 5878cba2..536c6d66 100644 --- a/docs/docs/CHANGELOG.md +++ b/docs/docs/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Expose [pprof endpoints](https://pkg.go.dev/net/http/pprof) on the metrics listener to enable profiling Anubis in production. - fix: prevent nil pointer panic in challenge validation when threshold rules match during PassChallenge (#1463) - Instruct reverse proxies to not cache error pages. - Fixed mixed tab/space indentation in Caddy documentation code block