-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
goroutine leak in package detected #182
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context
Hello, I'm currently working on open-telemetry/opentelemetry-collector-contrib#30438 to enable
goleak
to check for leaked goroutines.Bug
Here's the
goleak
output for the leaking goroutine:Here's the line that causing it:
seelog/behavior_asynclooplogger.go
Line 40 in f561c5e
This call is happening on
init()
, which means the goroutine is started when a package is imported, even if it isn't used.Solution
It's generally not good practice to start a goroutine in init. The best solution here would only be start the goroutine when required, and provide a public API to stop it.
Related:
#86
The text was updated successfully, but these errors were encountered: