mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
port over apiserver metric handler to use the instrumentation library
Change-Id: Ifabb726120c1c4f90ff3e4d71fdbba468fe74e8a
This commit is contained in:
parent
ef00707ccf
commit
6b994af680
@ -17,9 +17,6 @@ limitations under the License.
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
apimetrics "k8s.io/apiserver/pkg/endpoints/metrics"
|
apimetrics "k8s.io/apiserver/pkg/endpoints/metrics"
|
||||||
"k8s.io/apiserver/pkg/server/mux"
|
"k8s.io/apiserver/pkg/server/mux"
|
||||||
etcd3metrics "k8s.io/apiserver/pkg/storage/etcd3/metrics"
|
etcd3metrics "k8s.io/apiserver/pkg/storage/etcd3/metrics"
|
||||||
@ -43,18 +40,7 @@ type MetricsWithReset struct{}
|
|||||||
// Install adds the MetricsWithReset handler
|
// Install adds the MetricsWithReset handler
|
||||||
func (m MetricsWithReset) Install(c *mux.PathRecorderMux) {
|
func (m MetricsWithReset) Install(c *mux.PathRecorderMux) {
|
||||||
register()
|
register()
|
||||||
defaultMetricsHandler := legacyregistry.Handler().ServeHTTP
|
c.Handle("/metrics", legacyregistry.HandlerWithReset())
|
||||||
c.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
if req.Method == "DELETE" {
|
|
||||||
apimetrics.Reset()
|
|
||||||
etcd3metrics.Reset()
|
|
||||||
flowcontrolmetrics.Reset()
|
|
||||||
|
|
||||||
io.WriteString(w, "metrics reset\n")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defaultMetricsHandler(w, req)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// register apiserver and etcd metrics
|
// register apiserver and etcd metrics
|
||||||
|
Loading…
Reference in New Issue
Block a user