File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
281
281
"enable-pprof" ,
282
282
"" ,
283
283
false ,
284
- "Enables the pprof profiling server on the agent (port: 6060 )." ,
284
+ "Enables the pprof profiling endpoints on the agent server (port: 8081 )." ,
285
285
)
286
286
c .PersistentFlags ().BoolVarP (
287
287
& cfg .Prometheus ,
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ import (
34
34
"github.com/jetstack/preflight/pkg/logs"
35
35
"github.com/jetstack/preflight/pkg/version"
36
36
37
- _ "net/http/pprof"
37
+ "net/http/pprof"
38
38
)
39
39
40
40
var Flags AgentCmdFlags
@@ -74,19 +74,18 @@ func Run(cmd *cobra.Command, args []string) {
74
74
logs .Log .Fatalf ("While evaluating configuration: %v" , err )
75
75
}
76
76
77
- if Flags .Profiling {
78
- logs .Log .Printf ("pprof profiling was enabled.\n Running profiling on port :6060" )
79
- go func () {
80
- err := http .ListenAndServe (":6060" , nil )
81
- if err != nil && ! errors .Is (err , http .ErrServerClosed ) {
82
- logs .Log .Fatalf ("failed to run pprof profiler: %s" , err )
83
- }
84
- }()
85
- }
86
-
87
77
go func () {
88
78
server := http .NewServeMux ()
89
79
80
+ if Flags .Profiling {
81
+ logs .Log .Printf ("pprof profiling was enabled." )
82
+ server .HandleFunc ("/debug/pprof/" , pprof .Index )
83
+ server .HandleFunc ("/debug/pprof/cmdline" , pprof .Cmdline )
84
+ server .HandleFunc ("/debug/pprof/profile" , pprof .Profile )
85
+ server .HandleFunc ("/debug/pprof/symbol" , pprof .Symbol )
86
+ server .HandleFunc ("/debug/pprof/trace" , pprof .Trace )
87
+ }
88
+
90
89
if Flags .Prometheus {
91
90
logs .Log .Printf ("Prometheus was enabled.\n Running prometheus on port :8081" )
92
91
prometheus .MustRegister (metricPayloadSize )
You can’t perform that action at this time.
0 commit comments