Skip to content

Commit

Permalink
Export emitRuntimeStats to provide a workaround for goroutine leak. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ncabatoff committed Dec 8, 2020
1 parent 6fd5a4d commit e640e04
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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

0 comments on commit e640e04

Please sign in to comment.