// MetricsWithReset is a handler that resets metrics when DELETE is passed to the endpoint. func MetricsWithReset(w http.ResponseWriter, req *http.Request) { if req.Method == "DELETE" { apiservermetrics.Reset() etcdmetrics.Reset() io.WriteString(w, "metrics reset\n") return } defaultMetricsHandler(w, req) }
func (m MetricsWithReset) Install(mux *apiserver.PathRecorderMux, c *restful.Container) { defaultMetricsHandler := prometheus.Handler().ServeHTTP mux.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) { if req.Method == "DELETE" { apiservermetrics.Reset() etcdmetrics.Reset() io.WriteString(w, "metrics reset\n") return } defaultMetricsHandler(w, req) }) }
// Install adds the MetricsWithReset handler func (m MetricsWithReset) Install(c *mux.APIContainer) { defaultMetricsHandler := prometheus.Handler().ServeHTTP c.NonSwaggerRoutes.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) { if req.Method == "DELETE" { apiservermetrics.Reset() etcdmetrics.Reset() io.WriteString(w, "metrics reset\n") return } defaultMetricsHandler(w, req) }) }
func resetMetrics(w http.ResponseWriter, req *http.Request) { apiservermetrics.Reset() etcdmetrics.Reset() io.WriteString(w, "metrics reset\n") }