From 264187f90b39fc902a471bf7c39c25ae0aec3878 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sun, 28 Dec 2025 18:24:05 -0500 Subject: [PATCH] feat: expose pprof endpoints over metrics listener Signed-off-by: Xe Iaso --- cmd/anubis/main.go | 7 +++++++ docs/docs/CHANGELOG.md | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/anubis/main.go b/cmd/anubis/main.go index e21eeca1..69add901 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" @@ -542,6 +543,12 @@ func metricsServer(ctx context.Context, lg slog.Logger, done func()) { } }) + 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) + srv := http.Server{Handler: mux, ErrorLog: internal.GetFilteredHTTPLogger()} listener, metricsUrl := setupListener(*metricsBindNetwork, *metricsBind) lg.Debug("listening for metrics", "url", metricsUrl) diff --git a/docs/docs/CHANGELOG.md b/docs/docs/CHANGELOG.md index 0c4271c7..3028da88 100644 --- a/docs/docs/CHANGELOG.md +++ b/docs/docs/CHANGELOG.md @@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Add Polish locale ([#1292](https://github.com/TecharoHQ/anubis/pull/1309)) +- Add Polish locale ([#1292](https://github.com/TecharoHQ/anubis/pull/1309)). +- Expose [pprof endpoints](https://pkg.go.dev/net/http/pprof) on the metrics listener to enable profiling Anubis in production.