mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-27 15:16:35 +00:00
switch to go-kit logger
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -7,7 +7,8 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/log"
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
@@ -18,6 +19,8 @@ const (
|
||||
|
||||
// A DiskDriveInfoCollector is a Prometheus collector for a few WMI metrics in Win32_DiskDrive
|
||||
type DiskDriveInfoCollector struct {
|
||||
logger log.Logger
|
||||
|
||||
DiskInfo *prometheus.Desc
|
||||
Status *prometheus.Desc
|
||||
Size *prometheus.Desc
|
||||
@@ -25,10 +28,12 @@ type DiskDriveInfoCollector struct {
|
||||
Availability *prometheus.Desc
|
||||
}
|
||||
|
||||
func newDiskDriveInfoCollector() (Collector, error) {
|
||||
func newDiskDriveInfoCollector(logger log.Logger) (Collector, error) {
|
||||
const subsystem = "diskdrive"
|
||||
|
||||
return &DiskDriveInfoCollector{
|
||||
logger: log.With(logger, "collector", subsystem),
|
||||
|
||||
DiskInfo: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, subsystem, "info"),
|
||||
"General drive information",
|
||||
@@ -129,7 +134,7 @@ var (
|
||||
// Collect sends the metric values for each metric to the provided prometheus Metric channel.
|
||||
func (c *DiskDriveInfoCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) error {
|
||||
if desc, err := c.collect(ch); err != nil {
|
||||
log.Error("failed collecting disk_drive_info metrics:", desc, err)
|
||||
level.Error(c.logger).Log("msg", "failed collecting disk_drive_info metrics", "desc", desc, "err", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user