Merge pull request #93134 from logicalhan/metric-handler
Add reset handler to the instrumentation metric library and expose Reset on the metric registries Kubernetes-commit: 6ceb6c6845348e03ebeb055c0e71b80a7d77048f
This commit is contained in:
commit
72adfd2587
|
|
@ -680,7 +680,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/component-base",
|
||||
"Rev": "e98e6e533eb1"
|
||||
"Rev": "8085c015d167"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/gengo",
|
||||
|
|
|
|||
4
go.mod
4
go.mod
|
|
@ -44,7 +44,7 @@ require (
|
|||
k8s.io/api v0.0.0-20200716171716-e4973e079a11
|
||||
k8s.io/apimachinery v0.0.0-20200713125710-cc2fa4f57325
|
||||
k8s.io/client-go v0.0.0-20200713130842-319dbfd0ed29
|
||||
k8s.io/component-base v0.0.0-20200713132432-e98e6e533eb1
|
||||
k8s.io/component-base v0.0.0-20200720012042-8085c015d167
|
||||
k8s.io/klog/v2 v2.2.0
|
||||
k8s.io/kube-openapi v0.0.0-20200427153329-656914f816f9
|
||||
k8s.io/utils v0.0.0-20200619165400-6e3d28b6ed19
|
||||
|
|
@ -57,5 +57,5 @@ replace (
|
|||
k8s.io/api => k8s.io/api v0.0.0-20200716171716-e4973e079a11
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20200713125710-cc2fa4f57325
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20200713130842-319dbfd0ed29
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20200713132432-e98e6e533eb1
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20200720012042-8085c015d167
|
||||
)
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -508,7 +508,7 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
|
|||
k8s.io/api v0.0.0-20200716171716-e4973e079a11/go.mod h1:jXutK3obFCnsfnkm06ePMMz07MzBtfBdwb/tOGaxQDE=
|
||||
k8s.io/apimachinery v0.0.0-20200713125710-cc2fa4f57325/go.mod h1:eHbWZVMaaewmYBAUuRYnAmTTMtDhvpPNZuh8/6Yl7v0=
|
||||
k8s.io/client-go v0.0.0-20200713130842-319dbfd0ed29/go.mod h1:4DeUSdsqcLMsCjohGuc0/AzpQDCDYsgjd7oq0vlmFQY=
|
||||
k8s.io/component-base v0.0.0-20200713132432-e98e6e533eb1/go.mod h1:vP8oeTBkmx6vS0b48FQ1masOyJvdltkTeuaV28yaF8k=
|
||||
k8s.io/component-base v0.0.0-20200720012042-8085c015d167/go.mod h1:BviI2yFEXU8Qon3Iwf9nwwX0Vl4VdOgSxJboEq7Q9wg=
|
||||
k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0 h1:XRvcwJozkgZ1UQJmfMGpvRthQHOvihEhYtDfAaxMz/A=
|
||||
|
|
|
|||
|
|
@ -17,9 +17,6 @@ limitations under the License.
|
|||
package routes
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
apimetrics "k8s.io/apiserver/pkg/endpoints/metrics"
|
||||
"k8s.io/apiserver/pkg/server/mux"
|
||||
etcd3metrics "k8s.io/apiserver/pkg/storage/etcd3/metrics"
|
||||
|
|
@ -43,18 +40,7 @@ type MetricsWithReset struct{}
|
|||
// Install adds the MetricsWithReset handler
|
||||
func (m MetricsWithReset) Install(c *mux.PathRecorderMux) {
|
||||
register()
|
||||
defaultMetricsHandler := legacyregistry.Handler().ServeHTTP
|
||||
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)
|
||||
})
|
||||
c.Handle("/metrics", legacyregistry.HandlerWithReset())
|
||||
}
|
||||
|
||||
// register apiserver and etcd metrics
|
||||
|
|
|
|||
Loading…
Reference in New Issue