From 9f759d3cbc08f466bf39fe774d9b6b66925d5a3c Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Sat, 22 Jun 2024 09:08:18 -0400 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Sam Xie --- instrumentation/runtime/runtime.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/instrumentation/runtime/runtime.go b/instrumentation/runtime/runtime.go index 3221ac753f8..93b01314d8f 100644 --- a/instrumentation/runtime/runtime.go +++ b/instrumentation/runtime/runtime.go @@ -186,12 +186,14 @@ type goCollector struct { func newCollector(minimumInterval time.Duration) *goCollector { g := &goCollector{ - sampleBuffer: make([]metrics.Sample, 0, len(runtimeMetrics)), - sampleMap: make(map[string]*metrics.Sample, len(runtimeMetrics)), + sampleBuffer: make([]metrics.Sample, 0, len(runtimeMetrics)), + sampleMap: make(map[string]*metrics.Sample, len(runtimeMetrics)), + minimumInterval: minimumInterval, } for _, runtimeMetric := range runtimeMetrics { - g.sampleBuffer = append(g.sampleBuffer, metrics.Sample{Name: runtimeMetric}) - g.sampleMap[runtimeMetric] = &g.sampleBuffer[len(g.sampleBuffer)-1] + s := metrics.Sample{Name: runtimeMetric} + g.sampleBuffer = append(g.sampleBuffer, s) + g.sampleMap[runtimeMetric] = &s } return g }