From e2a36a11e9d93e1328e7833f81c47eddda3e0e60 Mon Sep 17 00:00:00 2001 From: Steven Swartz Date: Fri, 27 Dec 2024 11:11:59 -0500 Subject: [PATCH] Increment WaitGroup while cleaning-up old files --- internal/component/pyroscope/java/loop.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/component/pyroscope/java/loop.go b/internal/component/pyroscope/java/loop.go index ddd14a166..38254f0fb 100644 --- a/internal/component/pyroscope/java/loop.go +++ b/internal/component/pyroscope/java/loop.go @@ -71,7 +71,9 @@ func newProfilingLoop(pid int, target discovery.Target, logger log.Logger, profi return p } + p.wg.Add(1) go func() { + defer p.wg.Done() // Clean-up files that weren't removed up by a previous instance of alloy err := p.cleanupOldJFRFiles(jfrFileName) if err != nil {