diff --git a/changelog/16834.txt b/changelog/16834.txt new file mode 100644 index 000000000..70c7d341b --- /dev/null +++ b/changelog/16834.txt @@ -0,0 +1,3 @@ +```release-note:bug +command/debug: fix bug where monitor was not honoring configured duration +``` \ No newline at end of file diff --git a/command/debug.go b/command/debug.go index 8213507cd..71e1a97c8 100644 --- a/command/debug.go +++ b/command/debug.go @@ -1071,7 +1071,18 @@ func (c *DebugCommand) writeLogs(ctx context.Context) { } defer out.Close() - logCh, err := c.cachedClient.Sys().Monitor(ctx, "trace", c.logFormat) + // Create Monitor specific client based on the cached client + mClient, err := c.cachedClient.Clone() + if err != nil { + c.captureError("log", err) + return + } + mClient.SetToken(c.cachedClient.Token()) + + // Set timeout to match the context explicitly + mClient.SetClientTimeout(c.flagDuration + debugDurationGrace) + + logCh, err := mClient.Sys().Monitor(ctx, "trace", c.logFormat) if err != nil { c.captureError("log", err) return