diff --git a/collector/bcache_linux.go b/collector/bcache_linux.go index b940b44..da4eab5 100644 --- a/collector/bcache_linux.go +++ b/collector/bcache_linux.go @@ -36,7 +36,7 @@ type bcacheCollector struct { func NewBcacheCollector() (Collector, error) { fs, err := bcache.NewFS(*sysPath) if err != nil { - return nil, fmt.Errorf("failed to open sysfs: %v", err) + return nil, fmt.Errorf("failed to open sysfs: %w", err) } return &bcacheCollector{ @@ -49,7 +49,7 @@ func NewBcacheCollector() (Collector, error) { func (c *bcacheCollector) Update(ch chan<- prometheus.Metric) error { stats, err := c.fs.Stats() if err != nil { - return fmt.Errorf("failed to retrieve bcache stats: %v", err) + return fmt.Errorf("failed to retrieve bcache stats: %w", err) } for _, s := range stats { diff --git a/collector/buddyinfo.go b/collector/buddyinfo.go index f6dd5db..316766e 100644 --- a/collector/buddyinfo.go +++ b/collector/buddyinfo.go @@ -47,7 +47,7 @@ func NewBuddyinfoCollector() (Collector, error) { ) fs, err := procfs.NewFS(*procPath) if err != nil { - return nil, fmt.Errorf("failed to open procfs: %v", err) + return nil, fmt.Errorf("failed to open procfs: %w", err) } return &buddyinfoCollector{fs, desc}, nil } diff --git a/collector/cpu_linux.go b/collector/cpu_linux.go index c6404c3..c946520 100644 --- a/collector/cpu_linux.go +++ b/collector/cpu_linux.go @@ -47,7 +47,7 @@ func init() { func NewCPUCollector() (Collector, error) { fs, err := procfs.NewFS(*procPath) if err != nil { - return nil, fmt.Errorf("failed to open procfs: %v", err) + return nil, fmt.Errorf("failed to open procfs: %w", err) } return &cpuCollector{ fs: fs, diff --git a/collector/cpufreq_linux.go b/collector/cpufreq_linux.go index 22e0365..c4de4d5 100644 --- a/collector/cpufreq_linux.go +++ b/collector/cpufreq_linux.go @@ -40,7 +40,7 @@ func init() { func NewCPUFreqCollector() (Collector, error) { fs, err := sysfs.NewFS(*sysPath) if err != nil { - return nil, fmt.Errorf("failed to open sysfs: %v", err) + return nil, fmt.Errorf("failed to open sysfs: %w", err) } return &cpuFreqCollector{ diff --git a/collector/infiniband_linux.go b/collector/infiniband_linux.go index 828e40e..52bf9a2 100644 --- a/collector/infiniband_linux.go +++ b/collector/infiniband_linux.go @@ -40,7 +40,7 @@ func NewInfiniBandCollector() (Collector, error) { i.fs, err = sysfs.NewFS(*sysPath) if err != nil { - return nil, fmt.Errorf("failed to open sysfs: %v", err) + return nil, fmt.Errorf("failed to open sysfs: %w", err) } // Detailed description for all metrics. diff --git a/collector/ipvs_linux.go b/collector/ipvs_linux.go index d2cc480..6ac48b1 100644 --- a/collector/ipvs_linux.go +++ b/collector/ipvs_linux.go @@ -59,7 +59,7 @@ func newIPVSCollector() (*ipvsCollector, error) { c.fs, err = procfs.NewFS(*procPath) if err != nil { - return nil, fmt.Errorf("failed to open procfs: %v", err) + return nil, fmt.Errorf("failed to open procfs: %w", err) } c.connections = typedDesc{prometheus.NewDesc( diff --git a/collector/mdadm_linux.go b/collector/mdadm_linux.go index ce130f5..aced6cd 100644 --- a/collector/mdadm_linux.go +++ b/collector/mdadm_linux.go @@ -94,7 +94,7 @@ func (c *mdadmCollector) Update(ch chan<- prometheus.Metric) error { fs, errFs := procfs.NewFS(*procPath) if errFs != nil { - return fmt.Errorf("failed to open procfs: %v", errFs) + return fmt.Errorf("failed to open procfs: %w", errFs) } mdStats, err := fs.MDStat() diff --git a/collector/meminfo_openbsd.go b/collector/meminfo_openbsd.go index 75702ef..073fbe7 100644 --- a/collector/meminfo_openbsd.go +++ b/collector/meminfo_openbsd.go @@ -58,7 +58,7 @@ func (c *meminfoCollector) getMemInfo() (map[string]float64, error) { var bcstats C.struct_bcachestats if _, err := C.sysctl_uvmexp(&uvmexp); err != nil { - return nil, fmt.Errorf("sysctl CTL_VM VM_UVMEXP failed: %v", err) + return nil, fmt.Errorf("sysctl CTL_VM VM_UVMEXP failed: %w", err) } if _, err := C.sysctl_bcstats(&bcstats); err != nil { diff --git a/collector/mountstats_linux.go b/collector/mountstats_linux.go index 605b3db..eeb01b7 100644 --- a/collector/mountstats_linux.go +++ b/collector/mountstats_linux.go @@ -108,12 +108,12 @@ func init() { func NewMountStatsCollector() (Collector, error) { fs, err := procfs.NewFS(*procPath) if err != nil { - return nil, fmt.Errorf("failed to open procfs: %v", err) + return nil, fmt.Errorf("failed to open procfs: %w", err) } proc, err := fs.Self() if err != nil { - return nil, fmt.Errorf("failed to open /proc/self: %v", err) + return nil, fmt.Errorf("failed to open /proc/self: %w", err) } const ( @@ -505,12 +505,12 @@ func NewMountStatsCollector() (Collector, error) { func (c *mountStatsCollector) Update(ch chan<- prometheus.Metric) error { mounts, err := c.proc.MountStats() if err != nil { - return fmt.Errorf("failed to parse mountstats: %v", err) + return fmt.Errorf("failed to parse mountstats: %w", err) } mountsInfo, err := c.proc.MountInfo() if err != nil { - return fmt.Errorf("failed to parse mountinfo: %v", err) + return fmt.Errorf("failed to parse mountinfo: %w", err) } // store all seen nfsDeviceIdentifiers for deduplication diff --git a/collector/netclass_linux.go b/collector/netclass_linux.go index 040ded3..af4b487 100644 --- a/collector/netclass_linux.go +++ b/collector/netclass_linux.go @@ -44,7 +44,7 @@ func init() { func NewNetClassCollector() (Collector, error) { fs, err := sysfs.NewFS(*sysPath) if err != nil { - return nil, fmt.Errorf("failed to open sysfs: %v", err) + return nil, fmt.Errorf("failed to open sysfs: %w", err) } pattern := regexp.MustCompile(*netclassIgnoredDevices) return &netClassCollector{ diff --git a/collector/nfs_linux.go b/collector/nfs_linux.go index b5f6c64..05b241e 100644 --- a/collector/nfs_linux.go +++ b/collector/nfs_linux.go @@ -45,7 +45,7 @@ func init() { func NewNfsCollector() (Collector, error) { fs, err := nfs.NewFS(*procPath) if err != nil { - return nil, fmt.Errorf("failed to open procfs: %v", err) + return nil, fmt.Errorf("failed to open procfs: %w", err) } return &nfsCollector{ @@ -96,7 +96,7 @@ func (c *nfsCollector) Update(ch chan<- prometheus.Metric) error { log.Debugf("Not collecting NFS metrics: %s", err) return nil } - return fmt.Errorf("failed to retrieve nfs stats: %v", err) + return fmt.Errorf("failed to retrieve nfs stats: %w", err) } c.updateNFSNetworkStats(ch, &stats.Network) diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index fe6ff71..b5e7cf9 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -41,7 +41,7 @@ const ( func NewNFSdCollector() (Collector, error) { fs, err := nfs.NewFS(*procPath) if err != nil { - return nil, fmt.Errorf("failed to open procfs: %v", err) + return nil, fmt.Errorf("failed to open procfs: %w", err) } return &nfsdCollector{ @@ -62,7 +62,7 @@ func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { log.Debugf("Not collecting NFSd metrics: %s", err) return nil } - return fmt.Errorf("failed to retrieve nfsd stats: %v", err) + return fmt.Errorf("failed to retrieve nfsd stats: %w", err) } c.updateNFSdReplyCacheStats(ch, &stats.ReplyCache) diff --git a/collector/pressure_linux.go b/collector/pressure_linux.go index df8c266..2ed7ffb 100644 --- a/collector/pressure_linux.go +++ b/collector/pressure_linux.go @@ -45,7 +45,7 @@ func init() { func NewPressureStatsCollector() (Collector, error) { fs, err := procfs.NewFS(*procPath) if err != nil { - return nil, fmt.Errorf("failed to open procfs: %v", err) + return nil, fmt.Errorf("failed to open procfs: %w", err) } return &pressureStatsCollector{ diff --git a/collector/processes_linux.go b/collector/processes_linux.go index 52a47df..bb18a69 100644 --- a/collector/processes_linux.go +++ b/collector/processes_linux.go @@ -41,7 +41,7 @@ func init() { func NewProcessStatCollector() (Collector, error) { fs, err := procfs.NewFS(*procPath) if err != nil { - return nil, fmt.Errorf("failed to open procfs: %v", err) + return nil, fmt.Errorf("failed to open procfs: %w", err) } subsystem := "processes" return &processCollector{ diff --git a/collector/schedstat_linux.go b/collector/schedstat_linux.go index ae649ec..1c91a47 100644 --- a/collector/schedstat_linux.go +++ b/collector/schedstat_linux.go @@ -49,7 +49,7 @@ var ( func NewSchedstatCollector() (Collector, error) { fs, err := procfs.NewFS(*procPath) if err != nil { - return nil, fmt.Errorf("failed to open procfs: %v", err) + return nil, fmt.Errorf("failed to open procfs: %w", err) } return &schedstatCollector{fs: fs}, nil diff --git a/collector/sockstat_linux.go b/collector/sockstat_linux.go index d6c4c72..fceb0ed 100644 --- a/collector/sockstat_linux.go +++ b/collector/sockstat_linux.go @@ -45,7 +45,7 @@ func NewSockStatCollector() (Collector, error) { func (c *sockStatCollector) Update(ch chan<- prometheus.Metric) error { fs, err := procfs.NewFS(*procPath) if err != nil { - return fmt.Errorf("failed to open procfs: %v", err) + return fmt.Errorf("failed to open procfs: %w", err) } // If IPv4 and/or IPv6 are disabled on this kernel, handle it gracefully. @@ -55,7 +55,7 @@ func (c *sockStatCollector) Update(ch chan<- prometheus.Metric) error { case os.IsNotExist(err): log.Debug("IPv4 sockstat statistics not found, skipping") default: - return fmt.Errorf("failed to get IPv4 sockstat data: %v", err) + return fmt.Errorf("failed to get IPv4 sockstat data: %w", err) } stat6, err := fs.NetSockstat6() @@ -64,7 +64,7 @@ func (c *sockStatCollector) Update(ch chan<- prometheus.Metric) error { case os.IsNotExist(err): log.Debug("IPv6 sockstat statistics not found, skipping") default: - return fmt.Errorf("failed to get IPv6 sockstat data: %v", err) + return fmt.Errorf("failed to get IPv6 sockstat data: %w", err) } stats := []struct { diff --git a/collector/stat_linux.go b/collector/stat_linux.go index cd79e38..5e51d96 100644 --- a/collector/stat_linux.go +++ b/collector/stat_linux.go @@ -41,7 +41,7 @@ func init() { func NewStatCollector() (Collector, error) { fs, err := procfs.NewFS(*procPath) if err != nil { - return nil, fmt.Errorf("failed to open procfs: %v", err) + return nil, fmt.Errorf("failed to open procfs: %w", err) } return &statCollector{ fs: fs, diff --git a/collector/thermal_zone_linux.go b/collector/thermal_zone_linux.go index 13606da..b8a65cf 100644 --- a/collector/thermal_zone_linux.go +++ b/collector/thermal_zone_linux.go @@ -40,7 +40,7 @@ func init() { func NewThermalZoneCollector() (Collector, error) { fs, err := sysfs.NewFS(*sysPath) if err != nil { - return nil, fmt.Errorf("failed to open sysfs: %v", err) + return nil, fmt.Errorf("failed to open sysfs: %w", err) } return &thermalZoneCollector{ diff --git a/collector/timex.go b/collector/timex.go index 09cc4a6..7ef6920 100644 --- a/collector/timex.go +++ b/collector/timex.go @@ -160,7 +160,7 @@ func (c *timexCollector) Update(ch chan<- prometheus.Metric) error { status, err := unix.Adjtimex(timex) if err != nil { - return fmt.Errorf("failed to retrieve adjtimex stats: %v", err) + return fmt.Errorf("failed to retrieve adjtimex stats: %w", err) } if status == timeError { diff --git a/collector/wifi_linux.go b/collector/wifi_linux.go index b9830e4..8e0d4ee 100644 --- a/collector/wifi_linux.go +++ b/collector/wifi_linux.go @@ -170,13 +170,13 @@ func (c *wifiCollector) Update(ch chan<- prometheus.Metric) error { return nil } - return fmt.Errorf("failed to access wifi data: %v", err) + return fmt.Errorf("failed to access wifi data: %w", err) } defer stat.Close() ifis, err := stat.Interfaces() if err != nil { - return fmt.Errorf("failed to retrieve wifi interfaces: %v", err) + return fmt.Errorf("failed to retrieve wifi interfaces: %w", err) } for _, ifi := range ifis { diff --git a/collector/xfs_linux.go b/collector/xfs_linux.go index 9a7ad98..c92a48c 100644 --- a/collector/xfs_linux.go +++ b/collector/xfs_linux.go @@ -33,7 +33,7 @@ func init() { func NewXFSCollector() (Collector, error) { fs, err := xfs.NewFS(*procPath, *sysPath) if err != nil { - return nil, fmt.Errorf("failed to open sysfs: %v", err) + return nil, fmt.Errorf("failed to open sysfs: %w", err) } return &xfsCollector{ @@ -45,7 +45,7 @@ func NewXFSCollector() (Collector, error) { func (c *xfsCollector) Update(ch chan<- prometheus.Metric) error { stats, err := c.fs.SysStats() if err != nil { - return fmt.Errorf("failed to retrieve XFS stats: %v", err) + return fmt.Errorf("failed to retrieve XFS stats: %w", err) } for _, s := range stats {