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/zfs.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/zfs.go')
-rw-r--r-- | collector/zfs.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/collector/zfs.go b/collector/zfs.go index aa33688..093ded5 100644 --- a/collector/zfs.go +++ b/collector/zfs.go | |||
@@ -20,8 +20,9 @@ import ( | |||
20 | "errors" | 20 | "errors" |
21 | "strings" | 21 | "strings" |
22 | 22 | ||
23 | "github.com/go-kit/kit/log" | ||
24 | "github.com/go-kit/kit/log/level" | ||
23 | "github.com/prometheus/client_golang/prometheus" | 25 | "github.com/prometheus/client_golang/prometheus" |
24 | "github.com/prometheus/common/log" | ||
25 | ) | 26 | ) |
26 | 27 | ||
27 | var errZFSNotAvailable = errors.New("ZFS / ZFS statistics are not available") | 28 | var errZFSNotAvailable = errors.New("ZFS / ZFS statistics are not available") |
@@ -36,10 +37,11 @@ type zfsCollector struct { | |||
36 | linuxProcpathBase string | 37 | linuxProcpathBase string |
37 | linuxZpoolIoPath string | 38 | linuxZpoolIoPath string |
38 | linuxPathMap map[string]string | 39 | linuxPathMap map[string]string |
40 | logger log.Logger | ||
39 | } | 41 | } |
40 | 42 | ||
41 | // NewZFSCollector returns a new Collector exposing ZFS statistics. | 43 | // NewZFSCollector returns a new Collector exposing ZFS statistics. |
42 | func NewZFSCollector() (Collector, error) { | 44 | func NewZFSCollector(logger log.Logger) (Collector, error) { |
43 | return &zfsCollector{ | 45 | return &zfsCollector{ |
44 | linuxProcpathBase: "spl/kstat/zfs", | 46 | linuxProcpathBase: "spl/kstat/zfs", |
45 | linuxZpoolIoPath: "/*/io", | 47 | linuxZpoolIoPath: "/*/io", |
@@ -56,6 +58,7 @@ func NewZFSCollector() (Collector, error) { | |||
56 | "zfs_zfetch": "zfetchstats", | 58 | "zfs_zfetch": "zfetchstats", |
57 | "zfs_zil": "zil", | 59 | "zfs_zil": "zil", |
58 | }, | 60 | }, |
61 | logger: logger, | ||
59 | }, nil | 62 | }, nil |
60 | } | 63 | } |
61 | 64 | ||
@@ -63,7 +66,7 @@ func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error { | |||
63 | for subsystem := range c.linuxPathMap { | 66 | for subsystem := range c.linuxPathMap { |
64 | if err := c.updateZfsStats(subsystem, ch); err != nil { | 67 | if err := c.updateZfsStats(subsystem, ch); err != nil { |
65 | if err == errZFSNotAvailable { | 68 | if err == errZFSNotAvailable { |
66 | log.Debug(err) | 69 | level.Debug(c.logger).Log("err", err) |
67 | // ZFS /proc files are added as new features to ZFS arrive, it is ok to continue | 70 | // ZFS /proc files are added as new features to ZFS arrive, it is ok to continue |
68 | continue | 71 | continue |
69 | } | 72 | } |