diff options
author | Ben Ye <yb532204897@gmail.com> | 2019-12-31 11:19:37 -0500 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2019-12-31 17:19:37 +0100 |
commit | 2477c5c67dff7e7655a9d466450235e9c9eac193 (patch) | |
tree | 198cb44d48f454df765984bc614e1b1972a646e8 /collector/bonding_linux.go | |
parent | a80b7d0bc5ee93e704bab22e7592ed8b7d65899e (diff) | |
download | prometheus_node_collector-2477c5c67dff7e7655a9d466450235e9c9eac193.tar.bz2 prometheus_node_collector-2477c5c67dff7e7655a9d466450235e9c9eac193.tar.xz prometheus_node_collector-2477c5c67dff7e7655a9d466450235e9c9eac193.zip |
switch to go-kit/log (#1575)
Signed-off-by: yeya24 <yb532204897@gmail.com>
Diffstat (limited to 'collector/bonding_linux.go')
-rw-r--r-- | collector/bonding_linux.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/collector/bonding_linux.go b/collector/bonding_linux.go index f67e2a3..771786b 100644 --- a/collector/bonding_linux.go +++ b/collector/bonding_linux.go | |||
@@ -22,12 +22,14 @@ import ( | |||
22 | "path/filepath" | 22 | "path/filepath" |
23 | "strings" | 23 | "strings" |
24 | 24 | ||
25 | "github.com/go-kit/kit/log" | ||
26 | "github.com/go-kit/kit/log/level" | ||
25 | "github.com/prometheus/client_golang/prometheus" | 27 | "github.com/prometheus/client_golang/prometheus" |
26 | "github.com/prometheus/common/log" | ||
27 | ) | 28 | ) |
28 | 29 | ||
29 | type bondingCollector struct { | 30 | type bondingCollector struct { |
30 | slaves, active typedDesc | 31 | slaves, active typedDesc |
32 | logger log.Logger | ||
31 | } | 33 | } |
32 | 34 | ||
33 | func init() { | 35 | func init() { |
@@ -36,7 +38,7 @@ func init() { | |||
36 | 38 | ||
37 | // NewBondingCollector returns a newly allocated bondingCollector. | 39 | // NewBondingCollector returns a newly allocated bondingCollector. |
38 | // It exposes the number of configured and active slave of linux bonding interfaces. | 40 | // It exposes the number of configured and active slave of linux bonding interfaces. |
39 | func NewBondingCollector() (Collector, error) { | 41 | func NewBondingCollector(logger log.Logger) (Collector, error) { |
40 | return &bondingCollector{ | 42 | return &bondingCollector{ |
41 | slaves: typedDesc{prometheus.NewDesc( | 43 | slaves: typedDesc{prometheus.NewDesc( |
42 | prometheus.BuildFQName(namespace, "bonding", "slaves"), | 44 | prometheus.BuildFQName(namespace, "bonding", "slaves"), |
@@ -48,6 +50,7 @@ func NewBondingCollector() (Collector, error) { | |||
48 | "Number of active slaves per bonding interface.", | 50 | "Number of active slaves per bonding interface.", |
49 | []string{"master"}, nil, | 51 | []string{"master"}, nil, |
50 | ), prometheus.GaugeValue}, | 52 | ), prometheus.GaugeValue}, |
53 | logger: logger, | ||
51 | }, nil | 54 | }, nil |
52 | } | 55 | } |
53 | 56 | ||
@@ -57,7 +60,7 @@ func (c *bondingCollector) Update(ch chan<- prometheus.Metric) error { | |||
57 | bondingStats, err := readBondingStats(statusfile) | 60 | bondingStats, err := readBondingStats(statusfile) |
58 | if err != nil { | 61 | if err != nil { |
59 | if os.IsNotExist(err) { | 62 | if os.IsNotExist(err) { |
60 | log.Debugf("Not collecting bonding, file does not exist: %s", statusfile) | 63 | level.Debug(c.logger).Log("msg", "Not collecting bonding, file does not exist", "file", statusfile) |
61 | return nil | 64 | return nil |
62 | } | 65 | } |
63 | return err | 66 | return err |