From 6c7a1db6bfeccc0020bce50eb97cb83dedcef9e1 Mon Sep 17 00:00:00 2001 From: Kevin Pike Date: Mon, 5 Oct 2015 07:37:59 -0700 Subject: [PATCH] don't reuse memstats --- prometheus/go_collector.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/prometheus/go_collector.go b/prometheus/go_collector.go index c55c5d5..015e350 100644 --- a/prometheus/go_collector.go +++ b/prometheus/go_collector.go @@ -11,8 +11,6 @@ type goCollector struct { goroutines Gauge gcDesc *Desc - // memstats object to reuse - ms *runtime.MemStats // metrics to describe and collect metrics memStatsMetrics } @@ -21,7 +19,6 @@ type goCollector struct { // go process. func NewGoCollector() *goCollector { return &goCollector{ - ms: new(runtime.MemStats), goroutines: NewGauge(GaugeOpts{ Namespace: "go", Name: "goroutines", @@ -267,13 +264,14 @@ func (c *goCollector) Collect(ch chan<- Metric) { quantiles[0.0] = stats.PauseQuantiles[0].Seconds() ch <- MustNewConstSummary(c.gcDesc, uint64(stats.NumGC), float64(stats.PauseTotal.Seconds()), quantiles) - runtime.ReadMemStats(c.ms) + ms := &runtime.MemStats{} + runtime.ReadMemStats(ms) for _, i := range c.metrics { - ch <- MustNewConstMetric(i.desc, i.valType, i.eval(c.ms)) + ch <- MustNewConstMetric(i.desc, i.valType, i.eval(ms)) } } -// memStatsMetrics provide description, value, and value type for memstat metrics +// memStatsMetrics provide description, value, and value type for memstat metrics. type memStatsMetrics []struct { desc *Desc eval func(*runtime.MemStats) float64