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 <julius.volz@gmail.com>
This commit is contained in:
Julius Volz 2018-08-04 21:31:28 +02:00 committed by GitHub
parent 90521a65f8
commit 159e1537d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 15 deletions

View File

@ -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