Skip to content

Commit

Permalink
kube-ovn-monitor and kube-ovn-pinger export pprof path (#3657)
Browse files Browse the repository at this point in the history
like /debug/pprof/...

Signed-off-by: changluyi <clyi@alauda.io>
  • Loading branch information
changluyi committed Jan 22, 2024
1 parent 6256827 commit 2f7fdb2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cmd/ovn_monitor/ovn_monitor.go
Expand Up @@ -31,9 +31,9 @@ func CmdMain() {
go exporter.TryClientConnection()
}
exporter.StartOvnMetrics()

mux := http.NewServeMux()
if config.EnableMetrics {
http.Handle(config.MetricsPath, promhttp.Handler())
mux.Handle(config.MetricsPath, promhttp.Handler())
klog.Infoln("Listening on", config.ListenAddress)
}

Expand All @@ -57,6 +57,7 @@ func CmdMain() {
server := &http.Server{
Addr: addr,
ReadHeaderTimeout: 3 * time.Second,
Handler: mux,
}
util.LogFatalAndExit(server.ListenAndServe(), "failed to listen and server on %s", config.ListenAddress)
}
4 changes: 3 additions & 1 deletion cmd/pinger/pinger.go
Expand Up @@ -25,14 +25,16 @@ func CmdMain() {
util.LogFatalAndExit(err, "failed to parse config")
}
if config.Mode == "server" && config.EnableMetrics {
http.Handle("/metrics", promhttp.Handler())
mux := http.NewServeMux()
mux.Handle("/metrics", promhttp.Handler())

go func() {
// conform to Gosec G114
// https://github.com/securego/gosec#available-rules
server := &http.Server{
Addr: fmt.Sprintf("0.0.0.0:%d", config.Port),
ReadHeaderTimeout: 3 * time.Second,
Handler: mux,
}
util.LogFatalAndExit(server.ListenAndServe(), "failed to listen and serve on %s", server.Addr)
}()
Expand Down

0 comments on commit 2f7fdb2

Please sign in to comment.