Skip to content

Commit 6b994af

Browse files
author
Han Kang
committed
port over apiserver metric handler to use the instrumentation library
Change-Id: Ifabb726120c1c4f90ff3e4d71fdbba468fe74e8a
1 parent ef00707 commit 6b994af

File tree

1 file changed

+1
-15
lines changed
  • staging/src/k8s.io/apiserver/pkg/server/routes

1 file changed

+1
-15
lines changed

staging/src/k8s.io/apiserver/pkg/server/routes/metrics.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ limitations under the License.
1717
package routes
1818

1919
import (
20-
"io"
21-
"net/http"
22-
2320
apimetrics "k8s.io/apiserver/pkg/endpoints/metrics"
2421
"k8s.io/apiserver/pkg/server/mux"
2522
etcd3metrics "k8s.io/apiserver/pkg/storage/etcd3/metrics"
@@ -43,18 +40,7 @@ type MetricsWithReset struct{}
4340
// Install adds the MetricsWithReset handler
4441
func (m MetricsWithReset) Install(c *mux.PathRecorderMux) {
4542
register()
46-
defaultMetricsHandler := legacyregistry.Handler().ServeHTTP
47-
c.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) {
48-
if req.Method == "DELETE" {
49-
apimetrics.Reset()
50-
etcd3metrics.Reset()
51-
flowcontrolmetrics.Reset()
52-
53-
io.WriteString(w, "metrics reset\n")
54-
return
55-
}
56-
defaultMetricsHandler(w, req)
57-
})
43+
c.Handle("/metrics", legacyregistry.HandlerWithReset())
5844
}
5945

6046
// register apiserver and etcd metrics

0 commit comments

Comments
 (0)