enhance: support specific duration for profile collection
The default duration of cpu profile collection in net/http/pprof is 30 seconds. User should have chance to set the specific duration for the collection. Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
parent
ac01f20a8e
commit
a2a23d91ca
@ -89,10 +89,18 @@ var pprofHeapCommand = cli.Command{
|
||||
var pprofProfileCommand = cli.Command{
|
||||
Name: "profile",
|
||||
Usage: "CPU profile",
|
||||
Flags: []cli.Flag{
|
||||
cli.DurationFlag{
|
||||
Name: "seconds,s",
|
||||
Usage: "duration for collection (seconds)",
|
||||
Value: 30 * time.Second,
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) error {
|
||||
client := getPProfClient(context)
|
||||
|
||||
output, err := httpGetRequest(client, "/debug/pprof/profile")
|
||||
seconds := context.Duration("seconds").Seconds()
|
||||
output, err := httpGetRequest(client, fmt.Sprintf("/debug/pprof/profile?seconds=%v", seconds))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user