From c01a7c2c573619ef0cbe029e00aacb54c1191a97 Mon Sep 17 00:00:00 2001 From: Marc Tuduri Date: Wed, 27 Sep 2023 18:00:19 +0200 Subject: [PATCH] use pointers --- collector/arp_linux.go | 4 ++-- collector/bcache_linux.go | 4 ++-- collector/bonding_linux.go | 4 ++-- collector/boot_time_bsd.go | 2 +- collector/boot_time_solaris.go | 2 +- collector/btrfs_linux.go | 4 ++-- collector/buddyinfo.go | 2 +- collector/cgroups_linux.go | 2 +- collector/collector.go | 6 +++--- collector/conntrack_linux.go | 6 +++--- collector/cpu_darwin.go | 2 +- collector/cpu_dragonfly.go | 2 +- collector/cpu_freebsd.go | 2 +- collector/cpu_linux.go | 6 +++--- collector/cpu_netbsd.go | 2 +- collector/cpu_openbsd.go | 2 +- collector/cpu_solaris.go | 2 +- collector/cpu_vulnerabilities_linux.go | 4 ++-- collector/cpufreq_linux.go | 2 +- collector/cpufreq_solaris.go | 2 +- collector/devstat_dragonfly.go | 2 +- collector/devstat_freebsd.go | 2 +- collector/diskstats_darwin.go | 2 +- collector/diskstats_linux.go | 8 ++++---- collector/diskstats_linux_test.go | 4 ++-- collector/diskstats_openbsd.go | 2 +- collector/diskstats_openbsd_amd64.go | 2 +- collector/dmi.go | 2 +- collector/drbd_linux.go | 4 ++-- collector/drm_linux.go | 2 +- collector/edac_linux.go | 4 ++-- collector/entropy_linux.go | 2 +- collector/ethtool_linux.go | 4 ++-- collector/ethtool_linux_test.go | 6 +++--- collector/exec_bsd.go | 2 +- collector/fibrechannel_linux.go | 2 +- collector/filefd_linux.go | 4 ++-- collector/filesystem_common.go | 4 ++-- collector/filesystem_linux.go | 4 ++-- collector/filesystem_linux_test.go | 2 +- collector/hwmon_linux.go | 4 ++-- collector/infiniband_linux.go | 2 +- collector/interrupts_common.go | 4 ++-- collector/interrupts_linux.go | 2 +- collector/ipvs_linux.go | 4 ++-- collector/ksmd_linux.go | 4 ++-- collector/lnstat_linux.go | 4 ++-- collector/loadavg.go | 4 ++-- collector/loadavg_linux.go | 4 ++-- collector/loadavg_linux_test.go | 2 +- collector/logind_linux.go | 2 +- collector/mdadm_linux.go | 4 ++-- collector/meminfo.go | 4 ++-- collector/meminfo_numa_linux.go | 6 +++--- collector/memory_bsd.go | 2 +- collector/mountstats_linux.go | 2 +- collector/netclass_linux.go | 4 ++-- collector/netdev_common.go | 4 ++-- collector/netdev_linux.go | 4 ++-- collector/netisr_freebsd.go | 2 +- collector/netstat_linux.go | 4 ++-- collector/network_route_linux.go | 2 +- collector/nfs_linux.go | 2 +- collector/nfsd_linux.go | 2 +- collector/ntp.go | 2 +- collector/nvme_linux.go | 2 +- collector/os_release.go | 4 ++-- collector/os_release_test.go | 2 +- collector/paths_test.go | 4 ++-- collector/perf_linux.go | 2 +- collector/perf_linux_test.go | 4 ++-- collector/powersupplyclass.go | 4 ++-- collector/powersupplyclass_linux.go | 2 +- collector/pressure_linux.go | 2 +- collector/processes_linux.go | 4 ++-- collector/qdisc_linux.go | 4 ++-- collector/rapl_linux.go | 4 ++-- collector/runit.go | 4 ++-- collector/schedstat_linux.go | 2 +- collector/selinux_linux.go | 2 +- collector/slabinfo_linux.go | 2 +- collector/sockstat_linux.go | 4 ++-- collector/softirqs_common.go | 2 +- collector/softnet_linux.go | 2 +- collector/stat_linux.go | 4 ++-- collector/supervisord.go | 2 +- collector/sysctl_linux.go | 2 +- collector/systemd_linux.go | 2 +- collector/systemd_linux_test.go | 2 +- collector/tapestats_linux.go | 2 +- collector/tcpstat_linux.go | 4 ++-- collector/textfile.go | 2 +- collector/thermal_darwin.go | 2 +- collector/thermal_zone_linux.go | 2 +- collector/time.go | 4 ++-- collector/timex.go | 2 +- collector/udp_queues_linux.go | 2 +- collector/uname.go | 2 +- collector/vmstat_linux.go | 4 ++-- collector/wifi_linux.go | 4 ++-- collector/xfs_linux.go | 2 +- collector/zfs.go | 4 ++-- collector/zfs_freebsd.go | 3 ++- collector/zfs_solaris.go | 2 +- collector/zoneinfo_linux.go | 2 +- kingpinconfig/flags.go | 4 ++-- node_exporter.go | 4 ++-- 107 files changed, 163 insertions(+), 162 deletions(-) diff --git a/collector/arp_linux.go b/collector/arp_linux.go index 263f32942f..75059c1b7b 100644 --- a/collector/arp_linux.go +++ b/collector/arp_linux.go @@ -33,7 +33,7 @@ type arpCollector struct { deviceFilter deviceFilter entries *prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -47,7 +47,7 @@ type ArpConfig struct { } // NewARPCollector returns a new Collector exposing ARP stats. -func NewARPCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewARPCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/bcache_linux.go b/collector/bcache_linux.go index e5a24c9197..6773587bcb 100644 --- a/collector/bcache_linux.go +++ b/collector/bcache_linux.go @@ -33,7 +33,7 @@ func init() { type bcacheCollector struct { fs bcache.FS logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } type BcacheConfig struct { @@ -42,7 +42,7 @@ type BcacheConfig struct { // NewBcacheCollector returns a newly allocated bcacheCollector. // It exposes a number of Linux bcache statistics. -func NewBcacheCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewBcacheCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := bcache.NewFS(*config.Path.SysPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) diff --git a/collector/bonding_linux.go b/collector/bonding_linux.go index 5735eae244..df54552c7b 100644 --- a/collector/bonding_linux.go +++ b/collector/bonding_linux.go @@ -31,7 +31,7 @@ import ( type bondingCollector struct { slaves, active typedDesc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -40,7 +40,7 @@ func init() { // NewBondingCollector returns a newly allocated bondingCollector. // It exposes the number of configured and active slave of linux bonding interfaces. -func NewBondingCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewBondingCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &bondingCollector{ slaves: typedDesc{prometheus.NewDesc( prometheus.BuildFQName(namespace, "bonding", "slaves"), diff --git a/collector/boot_time_bsd.go b/collector/boot_time_bsd.go index f883185456..ba49b965b0 100644 --- a/collector/boot_time_bsd.go +++ b/collector/boot_time_bsd.go @@ -32,7 +32,7 @@ func init() { } // newBootTimeCollector returns a new Collector exposing system boot time on BSD systems. -func newBootTimeCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func newBootTimeCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &bootTimeCollector{ logger: logger, }, nil diff --git a/collector/boot_time_solaris.go b/collector/boot_time_solaris.go index 0dfc671bc8..758c30d647 100644 --- a/collector/boot_time_solaris.go +++ b/collector/boot_time_solaris.go @@ -31,7 +31,7 @@ func init() { registerCollector("boottime", defaultEnabled, newBootTimeCollector) } -func newBootTimeCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func newBootTimeCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &bootTimeCollector{ boottime: typedDesc{ prometheus.NewDesc( diff --git a/collector/btrfs_linux.go b/collector/btrfs_linux.go index faff82bedf..831e35d70b 100644 --- a/collector/btrfs_linux.go +++ b/collector/btrfs_linux.go @@ -33,7 +33,7 @@ import ( type btrfsCollector struct { fs btrfs.FS logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -41,7 +41,7 @@ func init() { } // NewBtrfsCollector returns a new Collector exposing Btrfs statistics. -func NewBtrfsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewBtrfsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := btrfs.NewFS(*config.Path.SysPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) diff --git a/collector/buddyinfo.go b/collector/buddyinfo.go index 42869082c1..4f5708d35d 100644 --- a/collector/buddyinfo.go +++ b/collector/buddyinfo.go @@ -41,7 +41,7 @@ func init() { } // NewBuddyinfoCollector returns a new Collector exposing buddyinfo stats. -func NewBuddyinfoCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewBuddyinfoCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { desc := prometheus.NewDesc( prometheus.BuildFQName(namespace, buddyInfoSubsystem, "blocks"), "Count of free blocks according to size.", diff --git a/collector/cgroups_linux.go b/collector/cgroups_linux.go index eaa680133c..4363a2149a 100644 --- a/collector/cgroups_linux.go +++ b/collector/cgroups_linux.go @@ -38,7 +38,7 @@ func init() { } // NewCgroupSummaryCollector returns a new Collector exposing a summary of cgroups. -func NewCgroupSummaryCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewCgroupSummaryCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/collector.go b/collector/collector.go index 85c9a5f400..32d2f496a9 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -50,14 +50,14 @@ const ( ) var ( - factories = make(map[string]func(config NodeCollectorConfig, logger log.Logger) (Collector, error)) + factories = make(map[string]func(config *NodeCollectorConfig, logger log.Logger) (Collector, error)) initiatedCollectorsMtx = sync.Mutex{} initiatedCollectors = make(map[string]Collector) collectorState = make(map[string]*bool) forcedCollectors = map[string]bool{} // collectors which have been explicitly enabled or disabled ) -func registerCollector(collector string, isDefaultEnabled bool, factory func(config NodeCollectorConfig, logger log.Logger) (Collector, error)) { +func registerCollector(collector string, isDefaultEnabled bool, factory func(config *NodeCollectorConfig, logger log.Logger) (Collector, error)) { var helpDefaultState string if isDefaultEnabled { helpDefaultState = "enabled" @@ -104,7 +104,7 @@ func collectorFlagAction(collector string) func(ctx *kingpin.ParseContext) error } // NewNodeCollector creates a new NodeCollector. -func NewNodeCollector(config NodeCollectorConfig, logger log.Logger, filters ...string) (*NodeCollector, error) { +func NewNodeCollector(config *NodeCollectorConfig, logger log.Logger, filters ...string) (*NodeCollector, error) { f := make(map[string]bool) for _, filter := range filters { enabled, exist := collectorState[filter] diff --git a/collector/conntrack_linux.go b/collector/conntrack_linux.go index cd6ceb8b56..a035fa935d 100644 --- a/collector/conntrack_linux.go +++ b/collector/conntrack_linux.go @@ -39,7 +39,7 @@ type conntrackCollector struct { earlyDrop *prometheus.Desc searchRestart *prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } type conntrackStatistics struct { @@ -58,7 +58,7 @@ func init() { } // NewConntrackCollector returns a new Collector exposing conntrack stats. -func NewConntrackCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewConntrackCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &conntrackCollector{ current: prometheus.NewDesc( prometheus.BuildFQName(namespace, "", "nf_conntrack_entries"), @@ -162,7 +162,7 @@ func (c *conntrackCollector) handleErr(err error) error { return fmt.Errorf("failed to retrieve conntrack stats: %w", err) } -func getConntrackStatistics(config NodeCollectorConfig) (*conntrackStatistics, error) { +func getConntrackStatistics(config *NodeCollectorConfig) (*conntrackStatistics, error) { c := conntrackStatistics{} fs, err := procfs.NewFS(*config.Path.ProcPath) diff --git a/collector/cpu_darwin.go b/collector/cpu_darwin.go index bacde20a1a..6076890638 100644 --- a/collector/cpu_darwin.go +++ b/collector/cpu_darwin.go @@ -61,7 +61,7 @@ func init() { } // NewCPUCollector returns a new Collector exposing CPU stats. -func NewCPUCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewCPUCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &statCollector{ cpu: nodeCPUSecondsDesc, logger: logger, diff --git a/collector/cpu_dragonfly.go b/collector/cpu_dragonfly.go index 1420c4368a..69de4abeae 100644 --- a/collector/cpu_dragonfly.go +++ b/collector/cpu_dragonfly.go @@ -86,7 +86,7 @@ func init() { } // NewStatCollector returns a new Collector exposing CPU stats. -func NewStatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewStatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &statCollector{ cpu: nodeCPUSecondsDesc, logger: logger, diff --git a/collector/cpu_freebsd.go b/collector/cpu_freebsd.go index d75b8adc65..7d999c3239 100644 --- a/collector/cpu_freebsd.go +++ b/collector/cpu_freebsd.go @@ -93,7 +93,7 @@ func init() { } // NewStatCollector returns a new Collector exposing CPU stats. -func NewStatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewStatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &statCollector{ cpu: typedDesc{nodeCPUSecondsDesc, prometheus.CounterValue}, temp: typedDesc{prometheus.NewDesc( diff --git a/collector/cpu_linux.go b/collector/cpu_linux.go index 12889fd347..7d4ea46a4f 100644 --- a/collector/cpu_linux.go +++ b/collector/cpu_linux.go @@ -52,7 +52,7 @@ type cpuCollector struct { cpuFlagsIncludeRegexp *regexp.Regexp cpuBugsIncludeRegexp *regexp.Regexp - config NodeCollectorConfig + config *NodeCollectorConfig } // Idle jump back limit in seconds. @@ -74,7 +74,7 @@ func init() { } // NewCPUCollector returns a new Collector exposing kernel/system statistics. -func NewCPUCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewCPUCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) @@ -254,7 +254,7 @@ func updateFieldInfo(valueList []string, filter *regexp.Regexp, desc *prometheus } // updateThermalThrottle reads /sys/devices/system/cpu/cpu* and expose thermal throttle statistics. -func (c *cpuCollector) updateThermalThrottle(config NodeCollectorConfig, ch chan<- prometheus.Metric) error { +func (c *cpuCollector) updateThermalThrottle(config *NodeCollectorConfig, ch chan<- prometheus.Metric) error { cpus, err := filepath.Glob(config.Path.sysFilePath("devices/system/cpu/cpu[0-9]*")) if err != nil { return err diff --git a/collector/cpu_netbsd.go b/collector/cpu_netbsd.go index 4f1e63fba2..776b45496b 100644 --- a/collector/cpu_netbsd.go +++ b/collector/cpu_netbsd.go @@ -222,7 +222,7 @@ func init() { } // NewStatCollector returns a new Collector exposing CPU stats. -func NewStatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewStatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &statCollector{ cpu: typedDesc{nodeCPUSecondsDesc, prometheus.CounterValue}, temp: typedDesc{prometheus.NewDesc( diff --git a/collector/cpu_openbsd.go b/collector/cpu_openbsd.go index 31c3d49ef2..96eb2b3326 100644 --- a/collector/cpu_openbsd.go +++ b/collector/cpu_openbsd.go @@ -52,7 +52,7 @@ func init() { registerCollector("cpu", defaultEnabled, NewCPUCollector) } -func NewCPUCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewCPUCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &cpuCollector{ cpu: typedDesc{nodeCPUSecondsDesc, prometheus.CounterValue}, logger: logger, diff --git a/collector/cpu_solaris.go b/collector/cpu_solaris.go index 40a0ec0637..34911033d3 100644 --- a/collector/cpu_solaris.go +++ b/collector/cpu_solaris.go @@ -36,7 +36,7 @@ func init() { registerCollector("cpu", defaultEnabled, NewCpuCollector) } -func NewCpuCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewCpuCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &cpuCollector{ cpu: typedDesc{nodeCPUSecondsDesc, prometheus.CounterValue}, logger: logger, diff --git a/collector/cpu_vulnerabilities_linux.go b/collector/cpu_vulnerabilities_linux.go index afa028c194..039d548602 100644 --- a/collector/cpu_vulnerabilities_linux.go +++ b/collector/cpu_vulnerabilities_linux.go @@ -35,14 +35,14 @@ var ( ) type cpuVulnerabilitiesCollector struct { - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { registerCollector(cpuVulerabilitiesCollector, defaultDisabled, NewVulnerabilitySysfsCollector) } -func NewVulnerabilitySysfsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewVulnerabilitySysfsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &cpuVulnerabilitiesCollector{config}, nil } diff --git a/collector/cpufreq_linux.go b/collector/cpufreq_linux.go index 973f416afa..cf8cc8569f 100644 --- a/collector/cpufreq_linux.go +++ b/collector/cpufreq_linux.go @@ -35,7 +35,7 @@ func init() { } // NewCPUFreqCollector returns a new Collector exposing kernel/system statistics. -func NewCPUFreqCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewCPUFreqCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := sysfs.NewFS(*config.Path.SysPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) diff --git a/collector/cpufreq_solaris.go b/collector/cpufreq_solaris.go index 481a6a80de..23492d9a51 100644 --- a/collector/cpufreq_solaris.go +++ b/collector/cpufreq_solaris.go @@ -36,7 +36,7 @@ func init() { registerCollector("cpufreq", defaultEnabled, NewCPUFreqCollector) } -func NewCpuFreqCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewCpuFreqCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &cpuFreqCollector{ logger: logger, }, nil diff --git a/collector/devstat_dragonfly.go b/collector/devstat_dragonfly.go index 953c965053..4ebf59d12c 100644 --- a/collector/devstat_dragonfly.go +++ b/collector/devstat_dragonfly.go @@ -106,7 +106,7 @@ func init() { } // NewDevstatCollector returns a new Collector exposing Device stats. -func NewDevstatCollector(config NodeCollectorConfiglogger log.Logger) (Collector, error) { +func NewDevstatCollector(config *NodeCollectorConfiglogger log.Logger) (Collector, error) { return &devstatCollector{ bytesDesc: prometheus.NewDesc( prometheus.BuildFQName(namespace, devstatSubsystem, "bytes_total"), diff --git a/collector/devstat_freebsd.go b/collector/devstat_freebsd.go index a8c96a1a1f..3bdd694146 100644 --- a/collector/devstat_freebsd.go +++ b/collector/devstat_freebsd.go @@ -51,7 +51,7 @@ func init() { } // NewDevstatCollector returns a new Collector exposing Device stats. -func NewDevstatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewDevstatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &devstatCollector{ devinfo: &C.struct_devinfo{}, bytes: typedDesc{prometheus.NewDesc( diff --git a/collector/diskstats_darwin.go b/collector/diskstats_darwin.go index 00ffa3fcd5..faae589a4c 100644 --- a/collector/diskstats_darwin.go +++ b/collector/diskstats_darwin.go @@ -43,7 +43,7 @@ func init() { } // NewDiskstatsCollector returns a new Collector exposing disk device stats. -func NewDiskstatsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewDiskstatsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { var diskLabelNames = []string{"device"} deviceFilter, err := newDiskstatsDeviceFilter(config.DiskstatsDeviceFilter, logger) diff --git a/collector/diskstats_linux.go b/collector/diskstats_linux.go index 33d79f0976..96f03cd2cd 100644 --- a/collector/diskstats_linux.go +++ b/collector/diskstats_linux.go @@ -86,8 +86,8 @@ type diskstatsCollector struct { deviceMapperInfoDesc typedFactorDesc ataDescs map[string]typedFactorDesc logger log.Logger - getUdevDeviceProperties func(NodeCollectorConfig, uint32, uint32) (udevInfo, error) - config NodeCollectorConfig + getUdevDeviceProperties func(*NodeCollectorConfig, uint32, uint32) (udevInfo, error) + config *NodeCollectorConfig } func init() { @@ -96,7 +96,7 @@ func init() { // NewDiskstatsCollector returns a new Collector exposing disk device stats. // Docs from https://www.kernel.org/doc/Documentation/iostats.txt -func NewDiskstatsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewDiskstatsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { var diskLabelNames = []string{"device"} fs, err := blockdevice.NewFS(*config.Path.ProcPath, *config.Path.SysPath) if err != nil { @@ -372,7 +372,7 @@ func (c *diskstatsCollector) Update(ch chan<- prometheus.Metric) error { return nil } -func getUdevDeviceProperties(config NodeCollectorConfig, major, minor uint32) (udevInfo, error) { +func getUdevDeviceProperties(config *NodeCollectorConfig, major, minor uint32) (udevInfo, error) { filename := config.Path.udevDataFilePath(fmt.Sprintf("b%d:%d", major, minor)) data, err := os.Open(filename) diff --git a/collector/diskstats_linux_test.go b/collector/diskstats_linux_test.go index 3225811d1a..f2540a6357 100644 --- a/collector/diskstats_linux_test.go +++ b/collector/diskstats_linux_test.go @@ -39,7 +39,7 @@ func (c testDiskStatsCollector) Describe(ch chan<- *prometheus.Desc) { prometheus.DescribeByCollect(c, ch) } -func NewTestDiskStatsCollector(config NodeCollectorConfig, logger log.Logger) (prometheus.Collector, error) { +func NewTestDiskStatsCollector(config *NodeCollectorConfig, logger log.Logger) (prometheus.Collector, error) { dsc, err := NewDiskstatsCollector(config, logger) if err != nil { return testDiskStatsCollector{}, err @@ -50,7 +50,7 @@ func NewTestDiskStatsCollector(config NodeCollectorConfig, logger log.Logger) (p } func TestDiskStats(t *testing.T) { - config := NodeCollectorConfig{ + config := &NodeCollectorConfig{ DiskstatsDeviceFilter: DiskstatsDeviceFilterConfig{ DeviceExclude: new(string), DeviceInclude: new(string), diff --git a/collector/diskstats_openbsd.go b/collector/diskstats_openbsd.go index 47bc8e0f31..0bd6804704 100644 --- a/collector/diskstats_openbsd.go +++ b/collector/diskstats_openbsd.go @@ -49,7 +49,7 @@ func init() { } // NewDiskstatsCollector returns a new Collector exposing disk device stats. -func NewDiskstatsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewDiskstatsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { deviceFilter, err := newDiskstatsDeviceFilter(config.DiskstatsDeviceFilter, logger) if err != nil { return nil, fmt.Errorf("failed to parse device filter flags: %w", err) diff --git a/collector/diskstats_openbsd_amd64.go b/collector/diskstats_openbsd_amd64.go index 395f714b61..44a755596a 100644 --- a/collector/diskstats_openbsd_amd64.go +++ b/collector/diskstats_openbsd_amd64.go @@ -60,7 +60,7 @@ func init() { } // NewDiskstatsCollector returns a new Collector exposing disk device stats. -func NewDiskstatsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewDiskstatsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { deviceFilter, err := newDiskstatsDeviceFilter(config.DiskstatsDeviceFilter, logger) if err != nil { return nil, fmt.Errorf("failed to parse device filter flags: %w", err) diff --git a/collector/dmi.go b/collector/dmi.go index dcba329d29..20fd7518d0 100644 --- a/collector/dmi.go +++ b/collector/dmi.go @@ -38,7 +38,7 @@ func init() { } // NewDMICollector returns a new Collector exposing DMI information. -func NewDMICollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewDMICollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := sysfs.NewFS(*config.Path.SysPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) diff --git a/collector/drbd_linux.go b/collector/drbd_linux.go index 9ffd118ad2..6a992b904a 100644 --- a/collector/drbd_linux.go +++ b/collector/drbd_linux.go @@ -80,14 +80,14 @@ type drbdCollector struct { stringPair map[string]drbdStringPairMetric connected *prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { registerCollector("drbd", defaultDisabled, newDRBDCollector) } -func newDRBDCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func newDRBDCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &drbdCollector{ numerical: map[string]drbdNumericalMetric{ "ns": newDRBDNumericalMetric( diff --git a/collector/drm_linux.go b/collector/drm_linux.go index a38eb2fba0..ed3fd185ae 100644 --- a/collector/drm_linux.go +++ b/collector/drm_linux.go @@ -46,7 +46,7 @@ func init() { } // NewDrmCollector returns a new Collector exposing /sys/class/drm/card?/device stats. -func NewDrmCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewDrmCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := sysfs.NewFS(*config.Path.SysPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) diff --git a/collector/edac_linux.go b/collector/edac_linux.go index bd87f8828d..eafe80dee4 100644 --- a/collector/edac_linux.go +++ b/collector/edac_linux.go @@ -40,7 +40,7 @@ type edacCollector struct { csRowCECount *prometheus.Desc csRowUECount *prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -48,7 +48,7 @@ func init() { } // NewEdacCollector returns a new Collector exposing edac stats. -func NewEdacCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewEdacCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &edacCollector{ ceCount: prometheus.NewDesc( prometheus.BuildFQName(namespace, edacSubsystem, "correctable_errors_total"), diff --git a/collector/entropy_linux.go b/collector/entropy_linux.go index f3a4588f30..1b13a65c26 100644 --- a/collector/entropy_linux.go +++ b/collector/entropy_linux.go @@ -36,7 +36,7 @@ func init() { } // NewEntropyCollector returns a new Collector exposing entropy stats. -func NewEntropyCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewEntropyCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/ethtool_linux.go b/collector/ethtool_linux.go index e05ed9e1cc..860445bf00 100644 --- a/collector/ethtool_linux.go +++ b/collector/ethtool_linux.go @@ -87,7 +87,7 @@ type EthtoolConfig struct { // makeEthtoolCollector is the internal constructor for EthtoolCollector. // This allows NewEthtoolTestCollector to override its .ethtool interface // for testing. -func makeEthtoolCollector(config NodeCollectorConfig, logger log.Logger) (*ethtoolCollector, error) { +func makeEthtoolCollector(config *NodeCollectorConfig, logger log.Logger) (*ethtoolCollector, error) { fs, err := sysfs.NewFS(*config.Path.SysPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) @@ -215,7 +215,7 @@ func buildEthtoolFQName(metric string) string { } // NewEthtoolCollector returns a new Collector exposing ethtool stats. -func NewEthtoolCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewEthtoolCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return makeEthtoolCollector(config, logger) } diff --git a/collector/ethtool_linux_test.go b/collector/ethtool_linux_test.go index ecd0ba049c..b2627bf84d 100644 --- a/collector/ethtool_linux_test.go +++ b/collector/ethtool_linux_test.go @@ -49,7 +49,7 @@ func (c testEthtoolCollector) Describe(ch chan<- *prometheus.Desc) { prometheus.DescribeByCollect(c, ch) } -func NewTestEthtoolCollector(config NodeCollectorConfig, logger log.Logger) (prometheus.Collector, error) { +func NewTestEthtoolCollector(config *NodeCollectorConfig, logger log.Logger) (prometheus.Collector, error) { dsc, err := NewEthtoolTestCollector(config, logger) if err != nil { return testEthtoolCollector{}, err @@ -255,7 +255,7 @@ func (e *EthtoolFixture) LinkInfo(intf string) (ethtool.EthtoolCmd, error) { return res, err } -func NewEthtoolTestCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewEthtoolTestCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { collector, err := makeEthtoolCollector(config, logger) collector.ethtool = &EthtoolFixture{ fixturePath: "fixtures/ethtool/", @@ -285,7 +285,7 @@ func TestBuildEthtoolFQName(t *testing.T) { } func TestEthToolCollector(t *testing.T) { - config := NodeCollectorConfig{ + config := &NodeCollectorConfig{ Ethtool: EthtoolConfig{ DeviceInclude: new(string), DeviceExclude: new(string), diff --git a/collector/exec_bsd.go b/collector/exec_bsd.go index de2cf76197..91fbc3b6e3 100644 --- a/collector/exec_bsd.go +++ b/collector/exec_bsd.go @@ -32,7 +32,7 @@ func init() { } // NewExecCollector returns a new Collector exposing system execution statistics. -func NewExecCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewExecCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { // From sys/vm/vm_meter.c: // All are of type CTLTYPE_UINT. // diff --git a/collector/fibrechannel_linux.go b/collector/fibrechannel_linux.go index 26426e7c2e..7a471ccb88 100644 --- a/collector/fibrechannel_linux.go +++ b/collector/fibrechannel_linux.go @@ -40,7 +40,7 @@ func init() { } // NewFibreChannelCollector returns a new Collector exposing FibreChannel stats. -func NewFibreChannelCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewFibreChannelCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { var i fibrechannelCollector var err error diff --git a/collector/filefd_linux.go b/collector/filefd_linux.go index ac6478ac8b..a067e00b7c 100644 --- a/collector/filefd_linux.go +++ b/collector/filefd_linux.go @@ -33,7 +33,7 @@ const ( type fileFDStatCollector struct { logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -41,7 +41,7 @@ func init() { } // NewFileFDStatCollector returns a new Collector exposing file-nr stats. -func NewFileFDStatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewFileFDStatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &fileFDStatCollector{logger, config}, nil } diff --git a/collector/filesystem_common.go b/collector/filesystem_common.go index 8d7d9c7dfa..8072781845 100644 --- a/collector/filesystem_common.go +++ b/collector/filesystem_common.go @@ -44,7 +44,7 @@ type filesystemCollector struct { filesDesc, filesFreeDesc *prometheus.Desc roDesc, deviceErrorDesc *prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } type filesystemLabels struct { @@ -73,7 +73,7 @@ func init() { } // NewFilesystemCollector returns a new Collector exposing filesystems stats. -func NewFilesystemCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewFilesystemCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { if *config.Filesystem.OldMountPointsExcluded != "" { if !config.Filesystem.MountPointsExcludeSet { level.Warn(logger).Log("msg", "--collector.filesystem.ignored-mount-points is DEPRECATED and will be removed in 2.0.0, use --collector.filesystem.mount-points-exclude") diff --git a/collector/filesystem_linux.go b/collector/filesystem_linux.go index 11a12b4178..963ab561b9 100644 --- a/collector/filesystem_linux.go +++ b/collector/filesystem_linux.go @@ -168,7 +168,7 @@ func stuckMountWatcher(mountTimeout *time.Duration, mountPoint string, success c } } -func mountPointDetails(config NodeCollectorConfig, logger log.Logger) ([]filesystemLabels, error) { +func mountPointDetails(config *NodeCollectorConfig, logger log.Logger) ([]filesystemLabels, error) { file, err := os.Open(config.Path.procFilePath("1/mounts")) if errors.Is(err, os.ErrNotExist) { // Fallback to `/proc/mounts` if `/proc/1/mounts` is missing due hidepid. @@ -183,7 +183,7 @@ func mountPointDetails(config NodeCollectorConfig, logger log.Logger) ([]filesys return parseFilesystemLabels(config, file) } -func parseFilesystemLabels(config NodeCollectorConfig, r io.Reader) ([]filesystemLabels, error) { +func parseFilesystemLabels(config *NodeCollectorConfig, r io.Reader) ([]filesystemLabels, error) { var filesystems []filesystemLabels scanner := bufio.NewScanner(r) diff --git a/collector/filesystem_linux_test.go b/collector/filesystem_linux_test.go index 8ce7650e3d..a76c888b54 100644 --- a/collector/filesystem_linux_test.go +++ b/collector/filesystem_linux_test.go @@ -24,7 +24,7 @@ import ( ) func Test_parseFilesystemLabelsError(t *testing.T) { - config := NodeCollectorConfig{} + config := &NodeCollectorConfig{} tests := []struct { name string in string diff --git a/collector/hwmon_linux.go b/collector/hwmon_linux.go index d6c3563e52..7ce6e904ee 100644 --- a/collector/hwmon_linux.go +++ b/collector/hwmon_linux.go @@ -49,7 +49,7 @@ func init() { type hwMonCollector struct { deviceFilter deviceFilter logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } type HwMonConfig struct { @@ -59,7 +59,7 @@ type HwMonConfig struct { // NewHwMonCollector returns a new Collector exposing /sys/class/hwmon stats // (similar to lm-sensors). -func NewHwMonCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewHwMonCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &hwMonCollector{ logger: logger, diff --git a/collector/infiniband_linux.go b/collector/infiniband_linux.go index 29f8804a41..15d3fb3e7a 100644 --- a/collector/infiniband_linux.go +++ b/collector/infiniband_linux.go @@ -40,7 +40,7 @@ func init() { } // NewInfiniBandCollector returns a new Collector exposing InfiniBand stats. -func NewInfiniBandCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewInfiniBandCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { var i infinibandCollector var err error diff --git a/collector/interrupts_common.go b/collector/interrupts_common.go index 9f2b4166f9..94c4b60ce0 100644 --- a/collector/interrupts_common.go +++ b/collector/interrupts_common.go @@ -25,7 +25,7 @@ import ( type interruptsCollector struct { desc typedDesc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -33,7 +33,7 @@ func init() { } // NewInterruptsCollector returns a new Collector exposing interrupts stats. -func NewInterruptsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewInterruptsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &interruptsCollector{ desc: typedDesc{prometheus.NewDesc( namespace+"_interrupts_total", diff --git a/collector/interrupts_linux.go b/collector/interrupts_linux.go index 05ff337513..b78aa33e90 100644 --- a/collector/interrupts_linux.go +++ b/collector/interrupts_linux.go @@ -55,7 +55,7 @@ type interrupt struct { values []string } -func getInterrupts(config NodeCollectorConfig) (map[string]interrupt, error) { +func getInterrupts(config *NodeCollectorConfig) (map[string]interrupt, error) { file, err := os.Open(config.Path.procFilePath("interrupts")) if err != nil { return nil, err diff --git a/collector/ipvs_linux.go b/collector/ipvs_linux.go index 73853fda88..266e9f805b 100644 --- a/collector/ipvs_linux.go +++ b/collector/ipvs_linux.go @@ -75,11 +75,11 @@ type IPVSConfig struct { // NewIPVSCollector sets up a new collector for IPVS metrics. It accepts the // "procfs" config parameter to override the default proc location (/proc). -func NewIPVSCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewIPVSCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return newIPVSCollector(config, logger) } -func newIPVSCollector(config NodeCollectorConfig, logger log.Logger) (*ipvsCollector, error) { +func newIPVSCollector(config *NodeCollectorConfig, logger log.Logger) (*ipvsCollector, error) { var ( c ipvsCollector err error diff --git a/collector/ksmd_linux.go b/collector/ksmd_linux.go index dbdf23d58e..091fb37305 100644 --- a/collector/ksmd_linux.go +++ b/collector/ksmd_linux.go @@ -32,7 +32,7 @@ var ( type ksmdCollector struct { metricDescs map[string]*prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -51,7 +51,7 @@ func getCanonicalMetricName(filename string) string { } // NewKsmdCollector returns a new Collector exposing kernel/system statistics. -func NewKsmdCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewKsmdCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { subsystem := "ksmd" descs := make(map[string]*prometheus.Desc) diff --git a/collector/lnstat_linux.go b/collector/lnstat_linux.go index 8ac99a2234..f74207b5fd 100644 --- a/collector/lnstat_linux.go +++ b/collector/lnstat_linux.go @@ -27,14 +27,14 @@ import ( type lnstatCollector struct { logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { registerCollector("lnstat", defaultDisabled, NewLnstatCollector) } -func NewLnstatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewLnstatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &lnstatCollector{logger, config}, nil } diff --git a/collector/loadavg.go b/collector/loadavg.go index 172ec4d0a9..086886c474 100644 --- a/collector/loadavg.go +++ b/collector/loadavg.go @@ -28,7 +28,7 @@ import ( type loadavgCollector struct { metric []typedDesc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -36,7 +36,7 @@ func init() { } // NewLoadavgCollector returns a new Collector exposing load average stats. -func NewLoadavgCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewLoadavgCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &loadavgCollector{ metric: []typedDesc{ {prometheus.NewDesc(namespace+"_load1", "1m load average.", nil, nil), prometheus.GaugeValue}, diff --git a/collector/loadavg_linux.go b/collector/loadavg_linux.go index 075eb2782b..28af2a2d30 100644 --- a/collector/loadavg_linux.go +++ b/collector/loadavg_linux.go @@ -24,7 +24,7 @@ import ( ) // Read loadavg from /proc. -func getLoad(config NodeCollectorConfig) (loads []float64, err error) { +func getLoad(config *NodeCollectorConfig) (loads []float64, err error) { data, err := os.ReadFile(config.Path.procFilePath("loadavg")) if err != nil { return nil, err @@ -37,7 +37,7 @@ func getLoad(config NodeCollectorConfig) (loads []float64, err error) { } // Parse /proc loadavg and return 1m, 5m and 15m. -func parseLoad(config NodeCollectorConfig, data string) (loads []float64, err error) { +func parseLoad(config *NodeCollectorConfig, data string) (loads []float64, err error) { loads = make([]float64, 3) parts := strings.Fields(data) if len(parts) < 3 { diff --git a/collector/loadavg_linux_test.go b/collector/loadavg_linux_test.go index 707fab62d4..cd96f3c01c 100644 --- a/collector/loadavg_linux_test.go +++ b/collector/loadavg_linux_test.go @@ -19,7 +19,7 @@ package collector import "testing" func TestLoad(t *testing.T) { - config := NodeCollectorConfig{} + config := &NodeCollectorConfig{} want := []float64{0.21, 0.37, 0.39} loads, err := parseLoad(config, "0.21 0.37 0.39 1/719 19737") diff --git a/collector/logind_linux.go b/collector/logind_linux.go index 0a087fbfee..265f87678c 100644 --- a/collector/logind_linux.go +++ b/collector/logind_linux.go @@ -86,7 +86,7 @@ func init() { } // NewLogindCollector returns a new Collector exposing logind statistics. -func NewLogindCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewLogindCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &logindCollector{logger}, nil } diff --git a/collector/mdadm_linux.go b/collector/mdadm_linux.go index 86c08b5793..1e3c7d383e 100644 --- a/collector/mdadm_linux.go +++ b/collector/mdadm_linux.go @@ -29,7 +29,7 @@ import ( type mdadmCollector struct { logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -37,7 +37,7 @@ func init() { } // NewMdadmCollector returns a new Collector exposing raid statistics. -func NewMdadmCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewMdadmCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &mdadmCollector{logger, config}, nil } diff --git a/collector/meminfo.go b/collector/meminfo.go index 020ff8aab7..26f85f5ada 100644 --- a/collector/meminfo.go +++ b/collector/meminfo.go @@ -32,7 +32,7 @@ const ( type meminfoCollector struct { logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -40,7 +40,7 @@ func init() { } // NewMeminfoCollector returns a new Collector exposing memory stats. -func NewMeminfoCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewMeminfoCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &meminfoCollector{logger, config}, nil } diff --git a/collector/meminfo_numa_linux.go b/collector/meminfo_numa_linux.go index 5725ec8698..94ed6bcb6d 100644 --- a/collector/meminfo_numa_linux.go +++ b/collector/meminfo_numa_linux.go @@ -46,7 +46,7 @@ type meminfoMetric struct { type meminfoNumaCollector struct { metricDescs map[string]*prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -54,7 +54,7 @@ func init() { } // NewMeminfoNumaCollector returns a new Collector exposing memory stats. -func NewMeminfoNumaCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewMeminfoNumaCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &meminfoNumaCollector{ metricDescs: map[string]*prometheus.Desc{}, logger: logger, @@ -81,7 +81,7 @@ func (c *meminfoNumaCollector) Update(ch chan<- prometheus.Metric) error { return nil } -func getMemInfoNuma(config NodeCollectorConfig) ([]meminfoMetric, error) { +func getMemInfoNuma(config *NodeCollectorConfig) ([]meminfoMetric, error) { var ( metrics []meminfoMetric ) diff --git a/collector/memory_bsd.go b/collector/memory_bsd.go index 67f3cb0064..f9c62a1cda 100644 --- a/collector/memory_bsd.go +++ b/collector/memory_bsd.go @@ -41,7 +41,7 @@ func init() { } // NewMemoryCollector returns a new Collector exposing memory stats. -func NewMemoryCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewMemoryCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { tmp32, err := unix.SysctlUint32("vm.stats.vm.v_page_size") if err != nil { return nil, fmt.Errorf("sysctl(vm.stats.vm.v_page_size) failed: %w", err) diff --git a/collector/mountstats_linux.go b/collector/mountstats_linux.go index c2515a3498..fb9bce5ca6 100644 --- a/collector/mountstats_linux.go +++ b/collector/mountstats_linux.go @@ -111,7 +111,7 @@ func init() { } // NewMountStatsCollector returns a new Collector exposing NFS statistics. -func NewMountStatsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewMountStatsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/netclass_linux.go b/collector/netclass_linux.go index a5ee6cadaf..38a6dd4da2 100644 --- a/collector/netclass_linux.go +++ b/collector/netclass_linux.go @@ -35,7 +35,7 @@ type netClassCollector struct { ignoredDevicesPattern *regexp.Regexp metricDescs map[string]*prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -50,7 +50,7 @@ type NetClassConfig struct { } // NewNetClassCollector returns a new Collector exposing network class stats. -func NewNetClassCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewNetClassCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := sysfs.NewFS(*config.Path.SysPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) diff --git a/collector/netdev_common.go b/collector/netdev_common.go index ce061c3a15..e789bdd3b8 100644 --- a/collector/netdev_common.go +++ b/collector/netdev_common.go @@ -35,7 +35,7 @@ type netDevCollector struct { metricDescsMutex sync.Mutex metricDescs map[string]*prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } type netDevStats map[string]map[string]uint64 @@ -55,7 +55,7 @@ type NetDevConfig struct { } // NewNetDevCollector returns a new Collector exposing network device stats. -func NewNetDevCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewNetDevCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { if *config.NetDev.OldDeviceInclude != "" { if *config.NetDev.DeviceInclude == "" { level.Warn(logger).Log("msg", "--collector.netdev.device-whitelist is DEPRECATED and will be removed in 2.0.0, use --collector.netdev.device-include") diff --git a/collector/netdev_linux.go b/collector/netdev_linux.go index afefd2bbb3..01d5501256 100644 --- a/collector/netdev_linux.go +++ b/collector/netdev_linux.go @@ -25,7 +25,7 @@ import ( "github.com/prometheus/procfs" ) -func getNetDevStats(config NodeCollectorConfig, netDevNetlink *bool, filter *deviceFilter, logger log.Logger) (netDevStats, error) { +func getNetDevStats(config *NodeCollectorConfig, netDevNetlink *bool, filter *deviceFilter, logger log.Logger) (netDevStats, error) { if *netDevNetlink { return netlinkStats(filter, logger) } @@ -136,7 +136,7 @@ func parseNetlinkStats(links []rtnetlink.LinkMessage, filter *deviceFilter, logg return metrics } -func procNetDevStats(config NodeCollectorConfig, filter *deviceFilter, logger log.Logger) (netDevStats, error) { +func procNetDevStats(config *NodeCollectorConfig, filter *deviceFilter, logger log.Logger) (netDevStats, error) { metrics := netDevStats{} fs, err := procfs.NewFS(*config.Path.ProcPath) diff --git a/collector/netisr_freebsd.go b/collector/netisr_freebsd.go index 4955728634..cc417b33c3 100644 --- a/collector/netisr_freebsd.go +++ b/collector/netisr_freebsd.go @@ -36,7 +36,7 @@ func init() { registerCollector("netisr", defaultEnabled, NewNetisrCollector) } -func NewNetisrCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewNetisrCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &netisrCollector{ sysctls: []bsdSysctl{ { diff --git a/collector/netstat_linux.go b/collector/netstat_linux.go index c55ebd7d10..a99d023e4f 100644 --- a/collector/netstat_linux.go +++ b/collector/netstat_linux.go @@ -37,7 +37,7 @@ const ( type netStatCollector struct { fieldPattern *regexp.Regexp logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -50,7 +50,7 @@ type NetStatConfig struct { // NewNetStatCollector takes and returns // a new Collector exposing network stats. -func NewNetStatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewNetStatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { pattern := regexp.MustCompile(*config.NetStat.Fields) return &netStatCollector{ fieldPattern: pattern, diff --git a/collector/network_route_linux.go b/collector/network_route_linux.go index f661e1ab7e..210636d117 100644 --- a/collector/network_route_linux.go +++ b/collector/network_route_linux.go @@ -39,7 +39,7 @@ func init() { } // NewNetworkRouteCollector returns a new Collector exposing systemd statistics. -func NewNetworkRouteCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewNetworkRouteCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { const subsystem = "network" routeInfoDesc := prometheus.NewDesc( diff --git a/collector/nfs_linux.go b/collector/nfs_linux.go index 21585534bc..c711e89136 100644 --- a/collector/nfs_linux.go +++ b/collector/nfs_linux.go @@ -48,7 +48,7 @@ func init() { } // NewNfsCollector returns a new Collector exposing NFS statistics. -func NewNfsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewNfsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := nfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index 9a0fb49327..5bd9590011 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -44,7 +44,7 @@ const ( ) // NewNFSdCollector returns a new Collector exposing /proc/net/rpc/nfsd statistics. -func NewNFSdCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewNFSdCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := nfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/ntp.go b/collector/ntp.go index 36b7c0c4b0..6a813380e7 100644 --- a/collector/ntp.go +++ b/collector/ntp.go @@ -62,7 +62,7 @@ type NTPConfig struct { // Default definition of "local" is: // - collector.ntp.server address is a loopback address (or collector.ntp.server-is-mine flag is turned on) // - the server is reachable with outgoin IP_TTL = 1 -func NewNtpCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewNtpCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { ipaddr := net.ParseIP(*config.NTP.Server) if !*config.NTP.ServerIsLocal && (ipaddr == nil || !ipaddr.IsLoopback()) { return nil, fmt.Errorf("only IP address of local NTP server is valid for --collector.ntp.server") diff --git a/collector/nvme_linux.go b/collector/nvme_linux.go index bb528a0ecd..601c9265be 100644 --- a/collector/nvme_linux.go +++ b/collector/nvme_linux.go @@ -37,7 +37,7 @@ func init() { } // NewNVMeCollector returns a new Collector exposing NVMe stats. -func NewNVMeCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewNVMeCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := sysfs.NewFS(*config.Path.SysPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) diff --git a/collector/os_release.go b/collector/os_release.go index 8d09f94755..62f0afd699 100644 --- a/collector/os_release.go +++ b/collector/os_release.go @@ -65,7 +65,7 @@ type osReleaseCollector struct { osReleaseFilenames []string // all os-release file names to check version float64 versionDesc *prometheus.Desc - config NodeCollectorConfig + config *NodeCollectorConfig } type Plist struct { @@ -82,7 +82,7 @@ func init() { } // NewOSCollector returns a new Collector exposing os-release information. -func NewOSCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewOSCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &osReleaseCollector{ logger: logger, infoDesc: prometheus.NewDesc( diff --git a/collector/os_release_test.go b/collector/os_release_test.go index 87451aa3ae..80cb0a25df 100644 --- a/collector/os_release_test.go +++ b/collector/os_release_test.go @@ -87,7 +87,7 @@ func TestUpdateStruct(t *testing.T) { } wantedVersion := 20.04 - collector, err := NewOSCollector(NodeCollectorConfig{}, log.NewNopLogger()) + collector, err := NewOSCollector(&NodeCollectorConfig{}, log.NewNopLogger()) if err != nil { t.Fatal(err) } diff --git a/collector/paths_test.go b/collector/paths_test.go index 1690ab90e2..7034ffa0cf 100644 --- a/collector/paths_test.go +++ b/collector/paths_test.go @@ -75,8 +75,8 @@ func TestCustomSysPath(t *testing.T) { } } -func newNodeCollectorWithPaths() NodeCollectorConfig { - return NodeCollectorConfig{Path: PathConfig{ +func newNodeCollectorWithPaths() *NodeCollectorConfig { + return &NodeCollectorConfig{Path: PathConfig{ ProcPath: new(string), SysPath: new(string), RootfsPath: new(string), diff --git a/collector/perf_linux.go b/collector/perf_linux.go index c7b855ba20..148c3322a1 100644 --- a/collector/perf_linux.go +++ b/collector/perf_linux.go @@ -300,7 +300,7 @@ func newPerfTracepointCollector( // NewPerfCollector returns a new perf based collector, it creates a profiler // per CPU. -func NewPerfCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewPerfCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { collector := &perfCollector{ perfHwProfilers: map[int]*perf.HardwareProfiler{}, perfSwProfilers: map[int]*perf.SoftwareProfiler{}, diff --git a/collector/perf_linux_test.go b/collector/perf_linux_test.go index e771ef9582..9eef00b8d3 100644 --- a/collector/perf_linux_test.go +++ b/collector/perf_linux_test.go @@ -44,7 +44,7 @@ func canTestPerf(t *testing.T) { func TestPerfCollector(t *testing.T) { canTestPerf(t) - collector, err := NewPerfCollector(NodeCollectorConfig{}, log.NewNopLogger()) + collector, err := NewPerfCollector(&NodeCollectorConfig{}, log.NewNopLogger()) if err != nil { t.Fatal(err) } @@ -64,7 +64,7 @@ func TestPerfCollector(t *testing.T) { } func TestPerfCollectorStride(t *testing.T) { - config := NodeCollectorConfig{} + config := &NodeCollectorConfig{} canTestPerf(t) diff --git a/collector/powersupplyclass.go b/collector/powersupplyclass.go index a4db906345..b869f6ca48 100644 --- a/collector/powersupplyclass.go +++ b/collector/powersupplyclass.go @@ -29,7 +29,7 @@ type powerSupplyClassCollector struct { ignoredPattern *regexp.Regexp metricDescs map[string]*prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -40,7 +40,7 @@ type PowerSupplyClassConfig struct { IgnoredPowerSupplies *string } -func NewPowerSupplyClassCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewPowerSupplyClassCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { pattern := regexp.MustCompile(*config.PowerSupplyClass.IgnoredPowerSupplies) return &powerSupplyClassCollector{ subsystem: "power_supply", diff --git a/collector/powersupplyclass_linux.go b/collector/powersupplyclass_linux.go index 01a0be2568..5fde7c086b 100644 --- a/collector/powersupplyclass_linux.go +++ b/collector/powersupplyclass_linux.go @@ -155,7 +155,7 @@ func pushPowerSupplyMetric(ch chan<- prometheus.Metric, subsystem string, name s ch <- prometheus.MustNewConstMetric(fieldDesc, valueType, value, powerSupplyName) } -func getPowerSupplyClassInfo(config NodeCollectorConfig, ignore *regexp.Regexp) (sysfs.PowerSupplyClass, error) { +func getPowerSupplyClassInfo(config *NodeCollectorConfig, ignore *regexp.Regexp) (sysfs.PowerSupplyClass, error) { fs, err := sysfs.NewFS(*config.Path.SysPath) if err != nil { return nil, err diff --git a/collector/pressure_linux.go b/collector/pressure_linux.go index bd0b5d45f7..22fb89f5e0 100644 --- a/collector/pressure_linux.go +++ b/collector/pressure_linux.go @@ -49,7 +49,7 @@ func init() { } // NewPressureStatsCollector returns a Collector exposing pressure stall information -func NewPressureStatsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewPressureStatsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/processes_linux.go b/collector/processes_linux.go index 8b9e3294a1..0579812f3c 100644 --- a/collector/processes_linux.go +++ b/collector/processes_linux.go @@ -40,7 +40,7 @@ type processCollector struct { pidUsed *prometheus.Desc pidMax *prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -48,7 +48,7 @@ func init() { } // NewProcessStatCollector returns a new Collector exposing process data read from the proc filesystem. -func NewProcessStatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewProcessStatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/qdisc_linux.go b/collector/qdisc_linux.go index 4e742a47ec..422520b885 100644 --- a/collector/qdisc_linux.go +++ b/collector/qdisc_linux.go @@ -38,7 +38,7 @@ type qdiscStatCollector struct { overlimits typedDesc qlength typedDesc backlog typedDesc - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -54,7 +54,7 @@ type QdiscConfig struct { } // NewQdiscStatCollector returns a new Collector exposing queuing discipline statistics. -func NewQdiscStatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewQdiscStatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { if *config.Qdisc.OldDeviceInclude != "" { if *config.Qdisc.DeviceInclude == "" { level.Warn(logger).Log("msg", "--collector.qdisk.device-include is DEPRECATED and will be removed in 2.0.0, use --collector.qdisc.device-include") diff --git a/collector/rapl_linux.go b/collector/rapl_linux.go index bd7df2197b..0ec9c4db6e 100644 --- a/collector/rapl_linux.go +++ b/collector/rapl_linux.go @@ -35,7 +35,7 @@ type raplCollector struct { logger log.Logger joulesMetricDesc *prometheus.Desc - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -47,7 +47,7 @@ type RaplConfig struct { } // NewRaplCollector returns a new Collector exposing RAPL metrics. -func NewRaplCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewRaplCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := sysfs.NewFS(*config.Path.SysPath) if err != nil { diff --git a/collector/runit.go b/collector/runit.go index 9d3a29daf3..cbacdaa5cc 100644 --- a/collector/runit.go +++ b/collector/runit.go @@ -29,7 +29,7 @@ type runitCollector struct { stateNormal typedDesc stateTimestamp typedDesc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -41,7 +41,7 @@ type RunitConfig struct { } // NewRunitCollector returns a new Collector exposing runit statistics. -func NewRunitCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewRunitCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { var ( subsystem = "service" constLabels = prometheus.Labels{"supervisor": "runit"} diff --git a/collector/schedstat_linux.go b/collector/schedstat_linux.go index cbd8c57789..d6d5b8b938 100644 --- a/collector/schedstat_linux.go +++ b/collector/schedstat_linux.go @@ -53,7 +53,7 @@ var ( ) // NewSchedstatCollector returns a new Collector exposing task scheduler statistics -func NewSchedstatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewSchedstatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/selinux_linux.go b/collector/selinux_linux.go index b5f5317fcd..ee88590211 100644 --- a/collector/selinux_linux.go +++ b/collector/selinux_linux.go @@ -34,7 +34,7 @@ func init() { } // NewSelinuxCollector returns a new Collector exposing SELinux statistics. -func NewSelinuxCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewSelinuxCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { const subsystem = "selinux" return &selinuxCollector{ diff --git a/collector/slabinfo_linux.go b/collector/slabinfo_linux.go index 254337209d..23aa74b3ef 100644 --- a/collector/slabinfo_linux.go +++ b/collector/slabinfo_linux.go @@ -35,7 +35,7 @@ func init() { registerCollector("slabinfo", defaultDisabled, NewSlabinfoCollector) } -func NewSlabinfoCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewSlabinfoCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/sockstat_linux.go b/collector/sockstat_linux.go index ca6c8ff66c..b045c63ac1 100644 --- a/collector/sockstat_linux.go +++ b/collector/sockstat_linux.go @@ -36,7 +36,7 @@ var pageSize = os.Getpagesize() type sockStatCollector struct { logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -44,7 +44,7 @@ func init() { } // NewSockStatCollector returns a new Collector exposing socket stats. -func NewSockStatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewSockStatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &sockStatCollector{logger, config}, nil } diff --git a/collector/softirqs_common.go b/collector/softirqs_common.go index 10822ddf24..29fbf91e46 100644 --- a/collector/softirqs_common.go +++ b/collector/softirqs_common.go @@ -35,7 +35,7 @@ func init() { } // NewSoftirqsCollector returns a new Collector exposing softirq stats. -func NewSoftirqsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewSoftirqsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { desc := typedDesc{prometheus.NewDesc( namespace+"_softirqs_functions_total", "Softirq counts per CPU.", diff --git a/collector/softnet_linux.go b/collector/softnet_linux.go index 3a242c71cf..af3ec1030e 100644 --- a/collector/softnet_linux.go +++ b/collector/softnet_linux.go @@ -46,7 +46,7 @@ func init() { } // NewSoftnetCollector returns a new Collector exposing softnet metrics. -func NewSoftnetCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewSoftnetCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/stat_linux.go b/collector/stat_linux.go index 3830f44468..f549306fea 100644 --- a/collector/stat_linux.go +++ b/collector/stat_linux.go @@ -34,7 +34,7 @@ type statCollector struct { procsBlocked *prometheus.Desc softIRQ *prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -46,7 +46,7 @@ type StatConfig struct { } // NewStatCollector returns a new Collector exposing kernel/system statistics. -func NewStatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewStatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/supervisord.go b/collector/supervisord.go index 8711012185..c70ed0603d 100644 --- a/collector/supervisord.go +++ b/collector/supervisord.go @@ -51,7 +51,7 @@ type SupervisordConfig struct { } // NewSupervisordCollector returns a new Collector exposing supervisord statistics. -func NewSupervisordCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewSupervisordCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { var ( subsystem = "supervisord" labelNames = []string{"name", "group"} diff --git a/collector/sysctl_linux.go b/collector/sysctl_linux.go index dec348ff42..a98d82afad 100644 --- a/collector/sysctl_linux.go +++ b/collector/sysctl_linux.go @@ -42,7 +42,7 @@ type SysctlConfig struct { IncludeInfo *[]string } -func NewSysctlCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewSysctlCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) diff --git a/collector/systemd_linux.go b/collector/systemd_linux.go index 69d918cbb5..2aa46716f6 100644 --- a/collector/systemd_linux.go +++ b/collector/systemd_linux.go @@ -84,7 +84,7 @@ type SystemdConfig struct { } // NewSystemdCollector returns a new Collector exposing systemd statistics. -func NewSystemdCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewSystemdCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { const subsystem = "systemd" unitDesc := prometheus.NewDesc( diff --git a/collector/systemd_linux_test.go b/collector/systemd_linux_test.go index 2844eb7b2c..c5b12cac8e 100644 --- a/collector/systemd_linux_test.go +++ b/collector/systemd_linux_test.go @@ -105,7 +105,7 @@ func TestSystemdIgnoreFilterDefaultKeepsAll(t *testing.T) { logger := log.NewNopLogger() defaultInclude := ".+" defaultExclude := ".+\\.(automount|device|mount|scope|slice)" - config := NodeCollectorConfig{Systemd: SystemdConfig{ + config := &NodeCollectorConfig{Systemd: SystemdConfig{ UnitInclude: &defaultInclude, UnitExclude: &defaultExclude, OldUnitInclude: new(string), diff --git a/collector/tapestats_linux.go b/collector/tapestats_linux.go index f16653d79d..38a326f3ae 100644 --- a/collector/tapestats_linux.go +++ b/collector/tapestats_linux.go @@ -53,7 +53,7 @@ type TapestatsConfig struct { // NewTapestatsCollector returns a new Collector exposing tape device stats. // Docs from https://www.kernel.org/doc/html/latest/scsi/st.html#sysfs-and-statistics-for-tape-devices -func NewTapestatsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewTapestatsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { var tapeLabelNames = []string{"device"} fs, err := sysfs.NewFS(*config.Path.SysPath) diff --git a/collector/tcpstat_linux.go b/collector/tcpstat_linux.go index 4165d558d6..d8fbc6d70b 100644 --- a/collector/tcpstat_linux.go +++ b/collector/tcpstat_linux.go @@ -61,7 +61,7 @@ const ( type tcpStatCollector struct { desc typedDesc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -69,7 +69,7 @@ func init() { } // NewTCPStatCollector returns a new Collector exposing network stats. -func NewTCPStatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewTCPStatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &tcpStatCollector{ desc: typedDesc{prometheus.NewDesc( prometheus.BuildFQName(namespace, "tcp", "connection_states"), diff --git a/collector/textfile.go b/collector/textfile.go index def07914ff..5e5db0aa8e 100644 --- a/collector/textfile.go +++ b/collector/textfile.go @@ -57,7 +57,7 @@ type TextFileConfig struct { // NewTextFileCollector returns a new Collector exposing metrics read from files // in the given textfile directory. -func NewTextFileCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewTextFileCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { c := &textFileCollector{ path: *config.TextFile.Directory, logger: logger, diff --git a/collector/thermal_darwin.go b/collector/thermal_darwin.go index d733097074..71835e0f26 100644 --- a/collector/thermal_darwin.go +++ b/collector/thermal_darwin.go @@ -67,7 +67,7 @@ func init() { } // NewThermCollector returns a new Collector exposing current CPU power levels. -func NewThermCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewThermCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &thermCollector{ cpuSchedulerLimit: typedDesc{ desc: prometheus.NewDesc( diff --git a/collector/thermal_zone_linux.go b/collector/thermal_zone_linux.go index e68ac882f5..748a823a78 100644 --- a/collector/thermal_zone_linux.go +++ b/collector/thermal_zone_linux.go @@ -43,7 +43,7 @@ func init() { } // NewThermalZoneCollector returns a new Collector exposing kernel/system statistics. -func NewThermalZoneCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewThermalZoneCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := sysfs.NewFS(*config.Path.SysPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) diff --git a/collector/time.go b/collector/time.go index 1d34cbb0b3..63d5868dc5 100644 --- a/collector/time.go +++ b/collector/time.go @@ -30,7 +30,7 @@ type timeCollector struct { clocksourcesAvailable typedDesc clocksourceCurrent typedDesc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -39,7 +39,7 @@ func init() { // NewTimeCollector returns a new Collector exposing the current system time in // seconds since epoch. -func NewTimeCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewTimeCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { const subsystem = "time" return &timeCollector{ now: typedDesc{prometheus.NewDesc( diff --git a/collector/timex.go b/collector/timex.go index 5fa6014eb6..f4d03d2389 100644 --- a/collector/timex.go +++ b/collector/timex.go @@ -66,7 +66,7 @@ func init() { } // NewTimexCollector returns a new Collector exposing adjtime(3) stats. -func NewTimexCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewTimexCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { const subsystem = "timex" return &timexCollector{ diff --git a/collector/udp_queues_linux.go b/collector/udp_queues_linux.go index 05f1b4ff51..1ea8c39cb2 100644 --- a/collector/udp_queues_linux.go +++ b/collector/udp_queues_linux.go @@ -40,7 +40,7 @@ func init() { } // NewUDPqueuesCollector returns a new Collector exposing network udp queued bytes. -func NewUDPqueuesCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewUDPqueuesCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/collector/uname.go b/collector/uname.go index e03101db1c..ba28b4d38d 100644 --- a/collector/uname.go +++ b/collector/uname.go @@ -53,7 +53,7 @@ func init() { } // NewUnameCollector returns new unameCollector. -func newUnameCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func newUnameCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &unameCollector{logger}, nil } diff --git a/collector/vmstat_linux.go b/collector/vmstat_linux.go index 5241425c07..bd285a2e38 100644 --- a/collector/vmstat_linux.go +++ b/collector/vmstat_linux.go @@ -35,7 +35,7 @@ const ( type vmStatCollector struct { fieldPattern *regexp.Regexp logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -47,7 +47,7 @@ type VmStatConfig struct { } // NewvmStatCollector returns a new Collector exposing vmstat stats. -func NewvmStatCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewvmStatCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { pattern := regexp.MustCompile(*config.VmStat.Fields) return &vmStatCollector{ fieldPattern: pattern, diff --git a/collector/wifi_linux.go b/collector/wifi_linux.go index 39ef3df5f5..4f27b6fce7 100644 --- a/collector/wifi_linux.go +++ b/collector/wifi_linux.go @@ -45,7 +45,7 @@ type wifiCollector struct { stationBeaconLossTotal *prometheus.Desc logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } func init() { @@ -67,7 +67,7 @@ type wifiStater interface { } // NewWifiCollector returns a new Collector exposing Wifi statistics. -func NewWifiCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewWifiCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { const ( subsystem = "wifi" ) diff --git a/collector/xfs_linux.go b/collector/xfs_linux.go index 819d1598cf..b6e6010dda 100644 --- a/collector/xfs_linux.go +++ b/collector/xfs_linux.go @@ -35,7 +35,7 @@ func init() { } // NewXFSCollector returns a new Collector exposing XFS statistics. -func NewXFSCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewXFSCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := xfs.NewFS(*config.Path.ProcPath, *config.Path.SysPath) if err != nil { return nil, fmt.Errorf("failed to open sysfs: %w", err) diff --git a/collector/zfs.go b/collector/zfs.go index 032a9b631b..082f8f2147 100644 --- a/collector/zfs.go +++ b/collector/zfs.go @@ -40,11 +40,11 @@ type zfsCollector struct { linuxZpoolStatePath string linuxPathMap map[string]string logger log.Logger - config NodeCollectorConfig + config *NodeCollectorConfig } // NewZFSCollector returns a new Collector exposing ZFS statistics. -func NewZFSCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewZFSCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &zfsCollector{ linuxProcpathBase: "spl/kstat/zfs", linuxZpoolIoPath: "/*/io", diff --git a/collector/zfs_freebsd.go b/collector/zfs_freebsd.go index 22267d3b33..1d4904f094 100644 --- a/collector/zfs_freebsd.go +++ b/collector/zfs_freebsd.go @@ -18,6 +18,7 @@ package collector import ( "fmt" + "strings" "github.com/go-kit/log" "github.com/go-kit/log/level" @@ -39,7 +40,7 @@ func init() { registerCollector(zfsCollectorSubsystem, defaultEnabled, NewZfsCollector) } -func NewZfsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewZfsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &zfsCollector{ sysctls: []bsdSysctl{ { diff --git a/collector/zfs_solaris.go b/collector/zfs_solaris.go index 721f265743..d78cc796bc 100644 --- a/collector/zfs_solaris.go +++ b/collector/zfs_solaris.go @@ -65,7 +65,7 @@ func init() { registerCollector(zfsCollectorSubsystem, defaultEnabled, NewZfsCollector) } -func NewZfsCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewZfsCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { return &zfsCollector{ abdstatsLinearCount: prometheus.NewDesc( prometheus.BuildFQName(namespace, zfsCollectorSubsystem, "abdstats_linear_count_total"), diff --git a/collector/zoneinfo_linux.go b/collector/zoneinfo_linux.go index eefc10953f..73793dd516 100644 --- a/collector/zoneinfo_linux.go +++ b/collector/zoneinfo_linux.go @@ -37,7 +37,7 @@ func init() { } // NewZoneinfoCollector returns a new Collector exposing zone stats. -func NewZoneinfoCollector(config NodeCollectorConfig, logger log.Logger) (Collector, error) { +func NewZoneinfoCollector(config *NodeCollectorConfig, logger log.Logger) (Collector, error) { fs, err := procfs.NewFS(*config.Path.ProcPath) if err != nil { return nil, fmt.Errorf("failed to open procfs: %w", err) diff --git a/kingpinconfig/flags.go b/kingpinconfig/flags.go index d0373acd7c..0a54320865 100644 --- a/kingpinconfig/flags.go +++ b/kingpinconfig/flags.go @@ -19,8 +19,8 @@ import ( "github.com/prometheus/procfs" ) -func AddFlags(a *kingpin.Application) collector.NodeCollectorConfig { - config := collector.NodeCollectorConfig{} +func AddFlags(a *kingpin.Application) *collector.NodeCollectorConfig { + config := &collector.NodeCollectorConfig{} config.Arp.DeviceInclude = a.Flag("collector.arp.device-include", "Regexp of arp devices to include (mutually exclusive to device-exclude).").String() config.Arp.DeviceExclude = a.Flag("collector.arp.device-exclude", "Regexp of arp devices to exclude (mutually exclusive to device-include).").String() diff --git a/node_exporter.go b/node_exporter.go index 612358f5b9..985d1b61db 100644 --- a/node_exporter.go +++ b/node_exporter.go @@ -49,11 +49,11 @@ type handler struct { exporterMetricsRegistry *prometheus.Registry includeExporterMetrics bool maxRequests int - collectorConfig collector.NodeCollectorConfig + collectorConfig *collector.NodeCollectorConfig logger log.Logger } -func newHandler(includeExporterMetrics bool, maxRequests int, collectorConfig collector.NodeCollectorConfig, logger log.Logger) *handler { +func newHandler(includeExporterMetrics bool, maxRequests int, collectorConfig *collector.NodeCollectorConfig, logger log.Logger) *handler { h := &handler{ exporterMetricsRegistry: prometheus.NewRegistry(), includeExporterMetrics: includeExporterMetrics,