Skip to content
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

Export emitRuntimeStats to provide a workaround for goroutine leak. #121

Merged
merged 1 commit into from Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions metrics.go
Expand Up @@ -228,12 +228,12 @@ func (m *Metrics) allowMetric(key []string, labels []Label) (bool, []Label) {
func (m *Metrics) collectStats() {
for {
time.Sleep(m.ProfileInterval)
m.emitRuntimeStats()
m.EmitRuntimeStats()
}
}

// Emits various runtime statsitics
func (m *Metrics) emitRuntimeStats() {
func (m *Metrics) EmitRuntimeStats() {
// Export number of Goroutines
numRoutines := runtime.NumGoroutine()
m.SetGauge([]string{"runtime", "num_goroutines"}, float32(numRoutines))
Expand Down
2 changes: 1 addition & 1 deletion metrics_test.go
Expand Up @@ -239,7 +239,7 @@ func TestMetrics_MeasureSince(t *testing.T) {
func TestMetrics_EmitRuntimeStats(t *testing.T) {
runtime.GC()
m, met := mockMetric()
met.emitRuntimeStats()
met.EmitRuntimeStats()

if m.getKeys()[0][0] != "runtime" || m.getKeys()[0][1] != "num_goroutines" {
t.Fatalf("bad key %v", m.getKeys())
Expand Down