From 1932bbe3400d36e08668ee5b3e9ee1a0230db878 Mon Sep 17 00:00:00 2001 From: Alex Bozhenko Date: Fri, 24 Oct 2025 12:31:55 -0700 Subject: [PATCH] add expvarz Signed-off-by: Alex Bozhenko --- server/monitor.go | 4 +++- server/server.go | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/monitor.go b/server/monitor.go index 83a239d5300..c59a47b81a6 100644 --- a/server/monitor.go +++ b/server/monitor.go @@ -1501,7 +1501,8 @@ func (s *Server) HandleRoot(w http.ResponseWriter, r *http.Request) { LeafNodes %s Gateways %s Raft Groups %s - Health Probe %s + Health Probe %s + Expvar %s Help `, @@ -1518,6 +1519,7 @@ func (s *Server) HandleRoot(w http.ResponseWriter, r *http.Request) { s.basePath(GatewayzPath), GatewayzPath, s.basePath(RaftzPath), RaftzPath, s.basePath(HealthzPath), HealthzPath, + s.basePath(ExpvarzPath), ExpvarzPath, ) } diff --git a/server/server.go b/server/server.go index fb3e472b87e..38982bd382e 100644 --- a/server/server.go +++ b/server/server.go @@ -44,6 +44,8 @@ import ( // Allow dynamic profiling. _ "net/http/pprof" + "expvar" + "github.com/klauspost/compress/s2" "github.com/nats-io/jwt/v2" "github.com/nats-io/nats-server/v2/logger" @@ -3017,6 +3019,7 @@ const ( HealthzPath = "/healthz" IPQueuesPath = "/ipqueuesz" RaftzPath = "/raftz" + ExpvarzPath = "/debug/vars" ) func (s *Server) basePath(p string) string { @@ -3135,6 +3138,8 @@ func (s *Server) startMonitoring(secure bool) error { mux.HandleFunc(s.basePath(IPQueuesPath), s.HandleIPQueuesz) // Raftz mux.HandleFunc(s.basePath(RaftzPath), s.HandleRaftz) + // Expvarz + mux.Handle(s.basePath(ExpvarzPath), expvar.Handler()) // Do not set a WriteTimeout because it could cause cURL/browser // to return empty response or unable to display page if the