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

CaptureDebugGCStats panics #276

Open
Setheck opened this issue Jun 5, 2020 · 1 comment
Open

CaptureDebugGCStats panics #276

Setheck opened this issue Jun 5, 2020 · 1 comment

Comments

@Setheck
Copy link

Setheck commented Jun 5, 2020

Just wanted to explore what GC stats were getting captured, so i added
go metrics.CaptureDebugGCStats(metrics.DefaultRegistry, 10*time.Second)

and It appears to panic because debugMetrics.ReadGCStats is a Timer interface that is never initialized.

version from go.mod is github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0

@hspens
Copy link

hspens commented Oct 13, 2020

I experienced the same issue and it appears that you need to register the stats prior to using the capture function.

Example:

package main

import (
    metrics "github.com/rcrowley/go-metrics"
)

func main() {
  metrics.RegisterDebugGCStats(metrics.DefaultRegistry)
  metrics.RegisterRuntimeMemStats(metrics.DefaultRegistry)

  go metrics.CaptureDebugGCStats(metrics.DefaultRegistry, 10*time.Second)
  go metrics.CaptureRuntimeMemStats(metrics.DefaultRegistry, 10*time.Second)

  go metrics.Log(metrics.DefaultRegistry, 2*time.Second, log.New(os.Stderr, "metrics: ", log.Lmicroseconds))

  for { select{ } }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants