Skip to content

Commit 1a5f9a3

Browse files
authored
Merge pull request #2710 from fuweid/enhance_support_duration_for_cpu_profile_collection
enhance: support specific duration for profile collection
2 parents 09aa58b + a2a23d9 commit 1a5f9a3

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cmd/ctr/commands/pprof/pprof.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,18 @@ var pprofHeapCommand = cli.Command{
8989
var pprofProfileCommand = cli.Command{
9090
Name: "profile",
9191
Usage: "CPU profile",
92+
Flags: []cli.Flag{
93+
cli.DurationFlag{
94+
Name: "seconds,s",
95+
Usage: "duration for collection (seconds)",
96+
Value: 30 * time.Second,
97+
},
98+
},
9299
Action: func(context *cli.Context) error {
93100
client := getPProfClient(context)
94101

95-
output, err := httpGetRequest(client, "/debug/pprof/profile")
102+
seconds := context.Duration("seconds").Seconds()
103+
output, err := httpGetRequest(client, fmt.Sprintf("/debug/pprof/profile?seconds=%v", seconds))
96104
if err != nil {
97105
return err
98106
}

0 commit comments

Comments
 (0)