Skip to content

Commit db87173

Browse files
author
t-falconnet
committed
ethtool-linux: split between create and show entry
Signed-off-by: t-falconnet <[email protected]>
1 parent b0708e4 commit db87173

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

collector/ethtool_linux.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ func (c *ethtoolCollector) Update(ch chan<- prometheus.Metric) error {
422422
val := stats[metric]
423423

424424
// Check to see if this metric exists; if not then create it and store it in c.entries.
425-
entry := c.entry(metric, metricFQName)
425+
entry := c.entryWithCreate(metric, metricFQName)
426426
ch <- prometheus.MustNewConstMetric(
427427
entry, prometheus.UntypedValue, float64(val), device)
428428
}
@@ -431,7 +431,7 @@ func (c *ethtoolCollector) Update(ch chan<- prometheus.Metric) error {
431431
return nil
432432
}
433433

434-
func (c *ethtoolCollector) entry(key, metricFQName string) *prometheus.Desc {
434+
func (c *ethtoolCollector) entryWithCreate(key, metricFQName string) *prometheus.Desc {
435435
c.entriesMutex.Lock()
436436
defer c.entriesMutex.Unlock()
437437

@@ -445,3 +445,9 @@ func (c *ethtoolCollector) entry(key, metricFQName string) *prometheus.Desc {
445445

446446
return c.entries[key]
447447
}
448+
449+
func (c *ethtoolCollector) entry(key) *prometheus.Desc {
450+
c.entriesMutex.Lock()
451+
defer c.entriesMutex.Unlock()
452+
return c.entries[key]
453+
}

0 commit comments

Comments
 (0)