Skip to content

Commit

Permalink
fix: avoid to use http.DefaultServeMux which includes defaults routes…
Browse files Browse the repository at this point in the history
… inited by go like /debug/pprof
  • Loading branch information
morlay committed Nov 26, 2024
1 parent 16ff02d commit bd42a3f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/metrics/metrics_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,15 @@ func (mc *Controller) Run(healthChan chan<- *healthcheck.ControllerHeartbeat, st
DefaultRegisterer.MustRegister(BuildInfo)
DefaultRegisterer.MustRegister(ControllerIpvsMetricsExportTime)

mux := &http.ServeMux{}

srv := &http.Server{
Addr: mc.MetricsAddr + ":" + strconv.Itoa(int(mc.MetricsPort)),
Handler: http.DefaultServeMux,
Handler: mux,
ReadHeaderTimeout: 5 * time.Second}

// add prometheus handler on metrics path
http.Handle(mc.MetricsPath, Handler())
mux.Handle(mc.MetricsPath, Handler())

go func() {
if err := srv.ListenAndServe(); err != nil {
Expand Down

0 comments on commit bd42a3f

Please sign in to comment.