From 159e1537d2d23cced0043153b7facafb8a86ac0a Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Sat, 4 Aug 2018 21:31:28 +0200 Subject: [PATCH] Remove /heap endpoint (#4460) It was added 5 years ago by Matt and I'm not sure anyone ever used it after public release (since we have /debug/pprof/heap as well). It also lacked error checking and allows people to write to disk over HTTP. Signed-off-by: Julius Volz --- web/web.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/web/web.go b/web/web.go index 5fa6309ab..e3a58d5eb 100644 --- a/web/web.go +++ b/web/web.go @@ -38,7 +38,6 @@ import ( "google.golang.org/grpc" - pprof_runtime "runtime/pprof" template_text "text/template" "github.com/cockroachdb/cmux" @@ -255,8 +254,6 @@ func New(logger log.Logger, o *Options) *Handler { router.Get("/version", readyf(h.version)) router.Get("/service-discovery", readyf(h.serviceDiscovery)) - router.Get("/heap", h.dumpHeap) - router.Get("/metrics", promhttp.Handler().ServeHTTP) router.Get("/federate", readyf(httputil.CompressionHandler{ @@ -877,18 +874,6 @@ func (h *Handler) executeTemplate(w http.ResponseWriter, name string, data inter io.WriteString(w, result) } -func (h *Handler) dumpHeap(w http.ResponseWriter, r *http.Request) { - target := fmt.Sprintf("/tmp/%d.heap", time.Now().Unix()) - f, err := os.Create(target) - if err != nil { - level.Error(h.logger).Log("msg", "Could not dump heap", "err", err) - } - fmt.Fprintf(w, "Writing to %s...", target) - defer f.Close() - pprof_runtime.WriteHeapProfile(f) - fmt.Fprintf(w, "Done") -} - // AlertStatus bundles alerting rules and the mapping of alert states to row classes. type AlertStatus struct { AlertingRules []*rules.AlertingRule