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
Enable and enforce goleak in all packages #30438
Comments
A couple notes from my initial efforts:
|
I decided to upgrade my bash script for adding
Sample output:
|
Here's the initial list of failing packages:
|
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> This PR contains 3 main changes: 1. Make a copy of the same file into every package whose `goleak` check is currently passing. The only change for the `package_test.go` file in each package is the package name itself. 2. Rename `processor/tailsamplingprocessor/main_test.go` to `package_test.go` for uniformity. `package_test.go` is the name we chose for core (see discussion [here](open-telemetry/opentelemetry-collector#9173 (comment))). 3. Run `make gotidy` to add `goleak` dependency. I included the script used to make these changes [in the issue](#30438 (comment)). **Link to tracking Issue:** <Issue number if applicable> #30438
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> This PR contains 3 main changes: 1. Make a copy of the same file into every package whose `goleak` check is currently passing. The only change for the `package_test.go` file in each package is the package name itself. 2. Rename `processor/tailsamplingprocessor/main_test.go` to `package_test.go` for uniformity. `package_test.go` is the name we chose for core (see discussion [here](open-telemetry/opentelemetry-collector#9173 (comment))). 3. Run `make gotidy` to add `goleak` dependency. I included the script used to make these changes [in the issue](open-telemetry#30438 (comment)). **Link to tracking Issue:** <Issue number if applicable> open-telemetry#30438
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> Enables goleak check on tests in the `alertmanager` exporter to ensure it's not leaking goroutines. This is a test only change. **Link to tracking Issue:** <Issue number if applicable> #30438 **Testing:** <Describe what testing was performed and which tests were added.> All tests are passing, goleak check is passing.
…try#30965) **Description:** This enables the `goleak` package for testing the Prometheus exporter. This helps to ensure no goroutines are leaked by this component. This is a test only change, the only updates are making sure all tests close the response body of `Get` calls. **Link to tracking Issue:** open-telemetry#30438 **Testing:** All tests are passing, including added `goleak` test.
…or jaegerremotesampling extension (open-telemetry#31661) Related to open-telemetry#30438 Resolves open-telemetry#31157 Signed-off-by: Israel Blancas <iblancasa@gmail.com>
**Description:** This enables `goleak` to help ensure no goroutines are being leaked in the `internal/docker` package. This is a test only change, an existing test was leaking a goroutine because it wasn't cancelling a context properly. **Link to tracking Issue:** open-telemetry#30438 **Testing:** Existing tests are passing, as well as added `goleak` check.
**Description:** This enables the `goleak` check for the Snowflake receiver to help ensure no goroutines are being leaked. This is a test only change, a couple shutdown/close calls were missing. **Link to tracking Issue:** open-telemetry#30438 **Testing:** All existing tests are passing, as well as added `goleak` check.
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> This change enables `goleak` to help ensure the ZooKeeper receiver does not leak any goroutines. This is a test only change, the existing test implementation needed a bit of modification to properly close the network listener. **Link to tracking Issue:** <Issue number if applicable> open-telemetry#30438 **Testing:** <Describe what testing was performed and which tests were added.> Existing tests and new `goleak` check are all passing.
This enables `goleak` checks for the sshcheck receiver to help ensure no goroutines are being leaked. This is a test only change. The test package's SSH Server needed to be modified to properly shutdown. **Link to tracking Issue:** open-telemetry#30438
Enable `goleak` check for the NGINX receiver to help ensure no goroutines are being leaked. This is a test only change, a couple test servers were missing `Close` calls. **Link to tracking Issue:** open-telemetry#30438
Enable `goleak` checking on the Podman receiver to help ensure no goroutines are being leaked. This is a test only change. **Link to tracking Issue:** open-telemetry#30438
Enable `goleak` check for the PureStorage Flash Array receiver to help ensure no goroutines are being leaked. This is a test only change. The `TestStart` test was missing a shutdown call, and once the shutdown call was added, it was a duplicate test to `TestShutdown`. I consolidated these two tests into one, called `TestStartAndShutdown`. **Link to tracking Issue:** open-telemetry#30438
This change enables `goleak` checks on the Pure Storage FlashBlade receiver to help ensure no goroutines are being leaked. This is a test only change as a test was missing a shutdown call. This looks like I deleted a test, but the two tests were identical, other than a missing shutdown call. Once the missing call was added they were identical, so I decided to delete one. I also consolidated err checking to remove the `err` variable and directly check the result of the `Start` and `Shutdown` methods. **Link to tracking Issue:** open-telemetry#30438
Enable `goleak` checks for the NSX-T receiver to help ensure no goroutines are being leaked. This is a test only change, some tests were missing close calls to servers. **Link to tracking Issue:** open-telemetry#30438
Enable `goleak` testing on the Pulsar receiver to help ensure no goroutines are being leaked. **Link to tracking Issue:** open-telemetry#30438
Enable `goleak` check for the SAP HANA receiver to help ensure no goroutines are being leaked. **Link to tracking Issue:** open-telemetry#30438
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> The receiver was starting a goroutine that would run without being stopped during shutdown. This changes the goroutine to be stopped during shutdown. `goleak` is also added as a part of this change. **Link to tracking Issue:** <Issue number if applicable> open-telemetry#30438 **Testing:** <Describe what testing was performed and which tests were added.> All existing tests are passing, as well as added `goleak` check.
…en-telemetry#32307) This is a test only change that enables `goleak` checks on some of the internal packages of the Google Cloud Spanner receiver to help ensure no goroutines are leaking. Some tests were missing shutdown calls so those have been added. **Link to tracking Issue:** open-telemetry#30438 All existing tests are passing, as well as added `goleak` checks.
…eck (open-telemetry#32311) Enable `goleak` checks inside the `internal` package of the Google Cloud PubSub receiver to help ensure no goroutines are leaking. This is a test only change, some closes/cancels were missing. Also, we need to pass a context to the grpc dial functionality, so switch from`Dial` -> `DialContext`. `Dial` is a wrapper for `DialContext` passing in `context.Background()`. **Link to tracking Issue:** open-telemetry#30438 Existing tests are passing, as well as added `goleak` check.
**Description:** This fixes a memory leak happening in the Fluent Forward receiver. `time.Sleep` was being called for a duration of 10 seconds, with no way to interrupt during shutdown. This updates the functionality to use a timer that can be stopped in the case of the context being cancelled. This also enables `goleak` checks on the Fluent Forward receiver to help ensure no goroutines are being leaked, and adds a missing `Shutdown` call. **Link to tracking Issue:** open-telemetry#30438 **Testing:** All existing tests are passing as well as added `goleak` checks.
…2364) **Description:** This enables `goleak` checks for the Azure Event Hub receiver to help ensure no goroutines are being leaked. This is a test only change, some goroutines were being detected as leaks simply because of the context.Background lifecycle. Using a cancel shows everything gets shutdown properly. **Link to tracking Issue:** open-telemetry#30438 **Testing:** All existing tests are passing, as well as added `goleak` check.
…craper (open-telemetry#32362) **Description:** Enable `goleak` check in the `internal/scraper/githubscraper` package of the Git Provider receiver to help ensure no goroutines are being leaked. This is a test only change, a `Close` call was missing on a server in a test. **Link to tracking Issue:** open-telemetry#30438 **Testing:** All existing tests are passing, as well as added `goleak` check.
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> Add `goleak` check to the namedpipe receiver to help ensure no goroutines are being leaked. **Link to tracking Issue:** <Issue number if applicable> open-telemetry#30438 **Testing:** <Describe what testing was performed and which tests were added.> None yet, I'm running on macOS and this is a Linux-only receiver. Relying on GitHub CI/CD to show results. I'll convert this to ready to review if it passes.
…32401) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> As explained [here](open-telemetry#30438 (comment)), components need to cancel all their work and background tasks before returning from `Shutdown`. My original [change for this component](open-telemetry#32364) to add `goleak` testing worked around the proper behavior. This PR fully addresses the `Shutdown` functionality to ensure the component behaves the way the spec requires. **Link to tracking Issue:** <Issue number if applicable> open-telemetry#30438 **Testing:** <Describe what testing was performed and which tests were added.> Tests are passing.
Enable `goleak` checks in the `internal/udppoller` package of the AWS X-Ray receiver to help ensure no goroutines are being leaked. This is a test only change, simply adding a few missing `Close` calls. **Link to tracking Issue:** open-telemetry#30438 All existing tests as well as added `goleak` checks are passing.
…etry#32462) **Description:** Enable `goleak` checks to help ensure no goroutines are being leaked. This is a test only change. **Link to tracking Issue:** open-telemetry#30438 **Testing:** All existing tests are passing, as well as added `goleak` check.
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> This enables `goleak` on the Apache receiver to help ensure no goroutines are leaking. This is a test only change, a test server wasn't properly being shutdown in a test. **Link to tracking Issue:** <Issue number if applicable> open-telemetry#30438 **Testing:** <Describe what testing was performed and which tests were added.> All existing tests are passing, as well as added `goleak` checks.
…etry#32574) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> From [`client.Do` documentation](https://pkg.go.dev/net/http#Client.Do), a client's response can safely be ignored when an error is returned, but must be handled in all other cases, even when a response code is not 2XX. This fixes the internal AKS detection to properly close the response body in the case of a non-200 status returned. This also enables `goleak` on the `internal/metadata/azure` package which helps ensure no goroutines are being leaked. `goleak` is what detected this bug. **Link to tracking Issue:** <Issue number if applicable> open-telemetry#30438 **Testing:** <Describe what testing was performed and which tests were added.> All existing tests are passing as well as added `goleak` check.
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> Enable `goleak` check on the Aerospike receiver to help ensure no goroutines are being leaked. **Link to tracking Issue:** <Issue number if applicable> open-telemetry#30438
The remotetap processor holds a map of channels for writing telemetry data to WebSockets when a client connects. The write process works by blocking on a given channel waiting for telemetry data coming through the processor's pipeline, then writing as soon as it comes in. This however can result in a leaked goroutine that blocks forever if data is not received, which is always the case when shutting down. This fixes the bug by closing and deleting all channels once all client connections have been shutdown gracefully. This fixes the blocking behavior during shutdown. This change also enables `goleak` to help ensure no goroutines are being leaked. **Link to tracking Issue:** open-telemetry#30438 --------- Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
…#32044) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> Documentation shows the existing usage of [`time.Tick` will leak a goroutine on shutdown](https://pkg.go.dev/time#Tick). This updates the `internal/common/ttlmap` tick functionality to use a ticker with a context that has a cancel function. This allows the ticker to be properly shut down. I don't believe this requires a changelog because no user-facing components were updated to actually call the shutdown function. It makes more sense to me to add those after this gets merged to keep this PR more concise. This also adds `goleak` to the package to help ensure goroutines aren't being leaked. **Link to tracking Issue:** <Issue number if applicable> Related to open-telemetry#30438 **Testing:** <Describe what testing was performed and which tests were added.> Existing tests are still passing, goleak check was failing before change, succeeds after. --------- Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
…2573) Enable `goleak` checks on the `groupbytrace` processor to help ensure no goroutines are being leaked. I filed open-telemetry#32572 to address an existing leak that needs more discussion. **Link to tracking Issue:** open-telemetry#32572 open-telemetry#30438 --------- Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
…pen-telemetry#32361) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> This PR contains the following changes: 1. Add `Close` call to the receiver's GRPC client. Without this, goroutines were being leaked on shutdown. 2. Change `grpc.Dial` -> `grpc.NewClient`. They offer the same functionality, but `Dial` is being deprecated in favor of `NewClient`. 3. Enable `goleak` checks on this receiver to help ensure no goroutines are being leaked. 4. Change a couple `Assert.Nil` calls to `Assert.NoError`. The output of `NoError` includes the error message if hit, `Nil` simply includes the object's address, i.e. `&status.Error{s:(*status.Status)(0xc00007e158)}` **Link to tracking Issue:** <Issue number if applicable> open-telemetry#30438 **Testing:** <Describe what testing was performed and which tests were added.> All existing tests are passing, as well as added goleak check.
Component(s)
No response
Is your feature request related to a problem? Please describe.
There's currently no widespread testing in this repository for detecting leaking
goroutines
. Leakedgoroutines
are a result of improperly handling concurrency in golang, and a common cause of memory leaks.Describe the solution you'd like
goleak is a testing tool used to detect leaking
goroutines
. This is currently being done in core (#9165) and would be useful in contrib as well.Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: