Skip to content

Commit 5536767

Browse files
committed
refactor: move function to where it is used
Signed-off-by: Ales Pour <[email protected]>
1 parent 1d9d76a commit 5536767

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

prometheus/go_collector.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ func (c *baseGoCollector) Collect(ch chan<- Metric) {
157157
ch <- MustNewConstMetric(c.goInfoDesc, GaugeValue, 1)
158158
}
159159

160-
func memstatNamespace(s string) string {
161-
return "go_memstats_" + s
162-
}
163-
164160
// memStatsMetric provide description, evaluator, runtime/metrics name, and
165161
// value type for memstat metric.
166162
type memStatsMetric struct {
@@ -172,10 +168,10 @@ type memStatsMetric struct {
172168
func (m *memStatsMetric) update(memStats *runtime.MemStats) Metric {
173169
current := m.eval(memStats)
174170
switch value := m.metric.(type) {
175-
case *counter:
176-
value.Add(current - m.last)
177-
case *gauge:
171+
case Gauge:
178172
value.Set(current)
173+
case Counter:
174+
value.Add(current - m.last)
179175
default:
180176
panic("unexpected metric type")
181177
}

prometheus/go_collector_go116.go

+4
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,7 @@ func (c *goCollector) msCollect(ch chan<- Metric, ms *runtime.MemStats) {
120120
ch <- MustNewConstMetric(i.desc, i.valType, i.eval(ms))
121121
}
122122
}
123+
124+
func memstatNamespace(s string) string {
125+
return "go_memstats_" + s
126+
}

0 commit comments

Comments
 (0)