Skip to content

test(registry): Add goleak-based goroutine leak detection - #1797

Merged
bwplotka merged 1 commit into
prometheus:mainfrom
surinkim:test/registry-goleak
Apr 24, 2025
Merged

test(registry): Add goleak-based goroutine leak detection#1797
bwplotka merged 1 commit into
prometheus:mainfrom
surinkim:test/registry-goleak

Conversation

@surinkim

Copy link
Copy Markdown
Contributor

test(registry): Add goleak-based goroutine leak detection test for Registry.Gather

This commit adds a new test case TestGatherDoesNotLeakGoroutines which verifies that repeated calls to Registry.Gather() do not leak goroutines.

  • 100 collectors are registered to a custom registry
  • Gather() is called 1000 times
  • goleak.VerifyNone ensures that no unexpected goroutines remain

This test serves as a future safeguard to detect goroutine leaks under heavy usage.

Signed-off-by: hyunuk <nnhope@hotmail.com>
@surinkim
surinkim force-pushed the test/registry-goleak branch from 44b3d1e to 2ac28a9 Compare April 13, 2025 15:15

@bwplotka bwplotka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM -- was there any historical leak that trigger this PR?

One thing to ensure -- does this upset client_golang importers in terms of extra dependency. I assume NO given we only import this in test, importers should not see it (in theory).

@bwplotka
bwplotka merged commit 96a5ad6 into prometheus:main Apr 24, 2025
@bwplotka

Copy link
Copy Markdown
Member

Thanks!

juliusmh pushed a commit to juliusmh/client_golang that referenced this pull request Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants