Skip to content

Commit e3c396e

Browse files
authored
Merge pull request #828 from j4ckstraw/fix-pprof
fix: fix pprof by using DefaultServeMux
2 parents 34b265a + e31cf7b commit e3c396e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: pkg/exporters/k8sexporter/k8s_exporter.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"context"
2121
"net"
2222
"net/http"
23-
_ "net/http/pprof"
23+
"net/http/pprof"
2424
"strconv"
2525

2626
"k8s.io/klog/v2"
@@ -95,6 +95,13 @@ func (ke *k8sExporter) startHTTPReporting(npdo *options.NodeProblemDetectorOptio
9595
util.ReturnHTTPJson(w, ke.conditionManager.GetConditions())
9696
})
9797

98+
// register pprof
99+
mux.HandleFunc("/debug/pprof/", pprof.Index)
100+
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
101+
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
102+
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
103+
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
104+
98105
addr := net.JoinHostPort(npdo.ServerAddress, strconv.Itoa(npdo.ServerPort))
99106
go func() {
100107
err := http.ListenAndServe(addr, mux)

0 commit comments

Comments
 (0)