diff --git a/.changelog/12359.txt b/.changelog/12359.txt new file mode 100644 index 000000000..6c6c3e451 --- /dev/null +++ b/.changelog/12359.txt @@ -0,0 +1,3 @@ +```release-note:improvement +debug: reduce the capture time for trace to only a single interval instead of the full duration to make trace.out easier to open without running into OOM errors. +``` diff --git a/command/debug/debug.go b/command/debug/debug.go index 1749d76b2..acbe36d93 100644 --- a/command/debug/debug.go +++ b/command/debug/debug.go @@ -413,7 +413,7 @@ func (c *cmd) captureLongRunning(ctx context.Context) error { g.Go(func() error { // use ctx without a timeout to allow the trace to finish sending - return c.captureTrace(ctx, s) + return c.captureTrace(ctx, int(c.interval.Seconds())) }) } if c.captureTarget(targetLogs) { @@ -443,8 +443,8 @@ func (c *cmd) captureGoRoutines(outputDir string) error { return ioutil.WriteFile(filepath.Join(outputDir, "goroutine.prof"), gr, 0644) } -func (c *cmd) captureTrace(ctx context.Context, s float64) error { - prof, err := c.client.Debug().PProf(ctx, "trace", int(s)) +func (c *cmd) captureTrace(ctx context.Context, duration int) error { + prof, err := c.client.Debug().PProf(ctx, "trace", duration) if err != nil { return fmt.Errorf("failed to collect cpu profile: %w", err) }