Ejemplo n.º 1
0
// 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)
}
Ejemplo n.º 2
0
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)
	})
}
Ejemplo n.º 3
0
// 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")
}