Skip to content

Commit

Permalink
Add remaining pprof profiles to debug dump
Browse files Browse the repository at this point in the history
  • Loading branch information
davemay99 committed Jun 21, 2021
1 parent fa1be62 commit 6690ec9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions command/operator_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,12 @@ func (c *OperatorDebugCommand) collectPprof(path, id string, client *api.Client)
}
}

err = c.savePprofProfile(path, "heap", opts, client)
err = c.savePprofProfile(path, "allocs", opts, client)
err = c.savePprofProfile(path, "threadcreate", opts, client)
err = c.savePprofProfile(path, "block", opts, client)
err = c.savePprofProfile(path, "mutex", opts, client)

// Gather goroutine text output - debug type 1
// debug type 1 writes the legacy text format for human readable output
opts.Debug = 1
Expand Down Expand Up @@ -702,6 +708,19 @@ func (c *OperatorDebugCommand) collectPprof(path, id string, client *api.Client)
}
}

// savePprofProfile collects a pprof profile from the client API and writes to disk
func (c *OperatorDebugCommand) savePprofProfile(path string, profile string, opts api.PprofOptions, client *api.Client) error {
bs, err := client.Agent().Lookup(profile, opts, nil)
if err != nil {
return fmt.Errorf("%s: Failed to retrieve pprof profile %s, err: %v", path, profile, err)
}

fileName := fmt.Sprintf("%s.prof", profile)
err = c.writeBytes(path, fileName, bs)

return err
}

// collectPeriodic runs for duration, capturing the cluster state every interval. It flushes and stops
// the monitor requests
func (c *OperatorDebugCommand) collectPeriodic(client *api.Client) {
Expand Down

0 comments on commit 6690ec9

Please sign in to comment.