switch to go-kit/log (#1575)

Signed-off-by: yeya24 <yb532204897@gmail.com>
This commit is contained in:
Ben Ye 2019-12-31 11:19:37 -05:00 committed by Ben Kochie
commit 2477c5c67d
158 changed files with 3434 additions and 4636 deletions

View file

@ -20,8 +20,9 @@ import (
"errors"
"strings"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
)
var errZFSNotAvailable = errors.New("ZFS / ZFS statistics are not available")
@ -36,10 +37,11 @@ type zfsCollector struct {
linuxProcpathBase string
linuxZpoolIoPath string
linuxPathMap map[string]string
logger log.Logger
}
// NewZFSCollector returns a new Collector exposing ZFS statistics.
func NewZFSCollector() (Collector, error) {
func NewZFSCollector(logger log.Logger) (Collector, error) {
return &zfsCollector{
linuxProcpathBase: "spl/kstat/zfs",
linuxZpoolIoPath: "/*/io",
@ -56,6 +58,7 @@ func NewZFSCollector() (Collector, error) {
"zfs_zfetch": "zfetchstats",
"zfs_zil": "zil",
},
logger: logger,
}, nil
}
@ -63,7 +66,7 @@ func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error {
for subsystem := range c.linuxPathMap {
if err := c.updateZfsStats(subsystem, ch); err != nil {
if err == errZFSNotAvailable {
log.Debug(err)
level.Debug(c.logger).Log("err", err)
// ZFS /proc files are added as new features to ZFS arrive, it is ok to continue
continue
}