Skip to content

Commit bd42a3f

Browse files
committed
fix: avoid to use http.DefaultServeMux which includes defaults routes inited by go like /debug/pprof
1 parent 16ff02d commit bd42a3f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/metrics/metrics_controller.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,15 @@ func (mc *Controller) Run(healthChan chan<- *healthcheck.ControllerHeartbeat, st
260260
DefaultRegisterer.MustRegister(BuildInfo)
261261
DefaultRegisterer.MustRegister(ControllerIpvsMetricsExportTime)
262262

263+
mux := &http.ServeMux{}
264+
263265
srv := &http.Server{
264266
Addr: mc.MetricsAddr + ":" + strconv.Itoa(int(mc.MetricsPort)),
265-
Handler: http.DefaultServeMux,
267+
Handler: mux,
266268
ReadHeaderTimeout: 5 * time.Second}
267269

268270
// add prometheus handler on metrics path
269-
http.Handle(mc.MetricsPath, Handler())
271+
mux.Handle(mc.MetricsPath, Handler())
270272

271273
go func() {
272274
if err := srv.ListenAndServe(); err != nil {

0 commit comments

Comments
 (0)