Skip to content

Commit

Permalink
ethtool_linux: fix entry function
Browse files Browse the repository at this point in the history
Signed-off-by: t-falconnet <tfalconnet.externe@bedrockstreaming.com>
  • Loading branch information
t-falconnet committed Feb 11, 2022
1 parent 4426962 commit 642f64b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions collector/ethtool_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func (c *ethtoolCollector) Update(ch chan<- prometheus.Metric) error {
val := stats[metric]

// Check to see if this metric exists; if not then create it and store it in c.entries.
entry := c.entries(metric)
entry := c.entry(metric, metricFQName)
ch <- prometheus.MustNewConstMetric(
entry, prometheus.UntypedValue, float64(val), device)
}
Expand All @@ -431,14 +431,14 @@ func (c *ethtoolCollector) Update(ch chan<- prometheus.Metric) error {
return nil
}

func (c *ethtoolCollector) entries(key string) *prometheus.Desc {
func (c *ethtoolCollector) entry(key, metricFQName string) *prometheus.Desc {
c.entriesMutex.Lock()
defer c.entriesMutex.Unlock()

if _, ok := c.entries[key]; !ok {
c.entries[key] = prometheus.NewDesc(
metricFQName,
fmt.Sprintf("Network interface %s", metric),
fmt.Sprintf("Network interface %s", key),
[]string{"device"}, nil,
)
}
Expand Down

0 comments on commit 642f64b

Please sign in to comment.