-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metrics: fix goroutine leaks in tests (#2505)
* adds Close() method to the Metrics interface * implements CodaHale metrics stats collector goroutines cleanup * fixes goroutine leaks in test Signed-off-by: Alexander Yastrebov <[email protected]>
- Loading branch information
1 parent
be73f2f
commit 2e836aa
Showing
9 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v0.16 | ||
v0.17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package metrics | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/AlexanderYastrebov/noleak" | ||
codahale "github.com/rcrowley/go-metrics" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
// codahale library has a global arbiter goroutine to update timers and there is no way to stop it, | ||
// see https://github.com/rcrowley/go-metrics/pull/46 | ||
// Create a dummy timer to start the arbiter goroutine before running tests such that leak detector does not report it. | ||
_ = codahale.NewTimer() | ||
|
||
os.Exit(noleak.CheckMain(m)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,3 +177,5 @@ func (m *MockMetrics) Gauge(key string) (v float64, ok bool) { | |
|
||
return | ||
} | ||
|
||
func (m *MockMetrics) Close() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters