Skip to content

Commit

Permalink
Apply v2.0.0 deprecations
Browse files Browse the repository at this point in the history
* Remove deprecated collectors.
* Remove deprecated flags.
* Flip rapl label feature flag to true.

Signed-off-by: Ben Kochie <superq@gmail.com>
  • Loading branch information
SuperQ committed Sep 11, 2024
1 parent 0909576 commit 6378027
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 563 deletions.
13 changes: 0 additions & 13 deletions collector/diskstats_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ var (
diskstatsDeviceExcludeSet = true
return nil
}).String()
oldDiskstatsDeviceExclude = kingpin.Flag(
"collector.diskstats.ignored-devices",
"DEPRECATED: Use collector.diskstats.device-exclude",
).Hidden().String()

diskstatsDeviceInclude = kingpin.Flag("collector.diskstats.device-include", "Regexp of diskstats devices to include (mutually exclusive to device-exclude).").String()

Expand Down Expand Up @@ -93,15 +89,6 @@ var (
)

func newDiskstatsDeviceFilter(logger *slog.Logger) (deviceFilter, error) {
if *oldDiskstatsDeviceExclude != "" {
if !diskstatsDeviceExcludeSet {
logger.Warn("--collector.diskstats.ignored-devices is DEPRECATED and will be removed in 2.0.0, use --collector.diskstats.device-exclude")
*diskstatsDeviceExclude = *oldDiskstatsDeviceExclude
} else {
return deviceFilter{}, errors.New("--collector.diskstats.ignored-devices and --collector.diskstats.device-exclude are mutually exclusive")
}
}

if *diskstatsDeviceExclude != "" && *diskstatsDeviceInclude != "" {
return deviceFilter{}, errors.New("device-exclude & device-include are mutually exclusive")
}
Expand Down
27 changes: 0 additions & 27 deletions collector/filesystem_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package collector

import (
"errors"
"log/slog"
"regexp"

Expand All @@ -41,10 +40,6 @@ var (
mountPointsExcludeSet = true
return nil
}).String()
oldMountPointsExcluded = kingpin.Flag(
"collector.filesystem.ignored-mount-points",
"Regexp of mount points to ignore for filesystem collector.",
).Hidden().String()

fsTypesExcludeSet bool
fsTypesExclude = kingpin.Flag(
Expand All @@ -54,10 +49,6 @@ var (
fsTypesExcludeSet = true
return nil
}).String()
oldFSTypesExcluded = kingpin.Flag(
"collector.filesystem.ignored-fs-types",
"Regexp of filesystem types to ignore for filesystem collector.",
).Hidden().String()

filesystemLabelNames = []string{"device", "mountpoint", "fstype", "device_error"}
)
Expand Down Expand Up @@ -89,24 +80,6 @@ func init() {

// NewFilesystemCollector returns a new Collector exposing filesystems stats.
func NewFilesystemCollector(logger *slog.Logger) (Collector, error) {
if *oldMountPointsExcluded != "" {
if !mountPointsExcludeSet {
logger.Warn("--collector.filesystem.ignored-mount-points is DEPRECATED and will be removed in 2.0.0, use --collector.filesystem.mount-points-exclude")
*mountPointsExclude = *oldMountPointsExcluded
} else {
return nil, errors.New("--collector.filesystem.ignored-mount-points and --collector.filesystem.mount-points-exclude are mutually exclusive")
}
}

if *oldFSTypesExcluded != "" {
if !fsTypesExcludeSet {
logger.Warn("--collector.filesystem.ignored-fs-types is DEPRECATED and will be removed in 2.0.0, use --collector.filesystem.fs-types-exclude")
*fsTypesExclude = *oldFSTypesExcluded
} else {
return nil, errors.New("--collector.filesystem.ignored-fs-types and --collector.filesystem.fs-types-exclude are mutually exclusive")
}
}

subsystem := "filesystem"
logger.Info("Parsed flag --collector.filesystem.mount-points-exclude", "flag", *mountPointsExclude)
mountPointPattern := regexp.MustCompile(*mountPointsExclude)
Expand Down
28 changes: 4 additions & 24 deletions collector/netdev_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ import (
)

var (
netdevDeviceInclude = kingpin.Flag("collector.netdev.device-include", "Regexp of net devices to include (mutually exclusive to device-exclude).").String()
oldNetdevDeviceInclude = kingpin.Flag("collector.netdev.device-whitelist", "DEPRECATED: Use collector.netdev.device-include").Hidden().String()
netdevDeviceExclude = kingpin.Flag("collector.netdev.device-exclude", "Regexp of net devices to exclude (mutually exclusive to device-include).").String()
oldNetdevDeviceExclude = kingpin.Flag("collector.netdev.device-blacklist", "DEPRECATED: Use collector.netdev.device-exclude").Hidden().String()
netdevAddressInfo = kingpin.Flag("collector.netdev.address-info", "Collect address-info for every device").Bool()
netdevDetailedMetrics = kingpin.Flag("collector.netdev.enable-detailed-metrics", "Use (incompatible) metric names that provide more detailed stats on Linux").Bool()
netdevDeviceInclude = kingpin.Flag("collector.netdev.device-include", "Regexp of net devices to include (mutually exclusive to device-exclude).").String()
netdevDeviceExclude = kingpin.Flag("collector.netdev.device-exclude", "Regexp of net devices to exclude (mutually exclusive to device-include).").String()
netdevAddressInfo = kingpin.Flag("collector.netdev.address-info", "Collect address-info for every device").Bool()
netdevDetailedMetrics = kingpin.Flag("collector.netdev.enable-detailed-metrics", "Use (incompatible) metric names that provide more detailed stats on Linux").Bool()
)

type netDevCollector struct {
Expand All @@ -54,24 +52,6 @@ func init() {

// NewNetDevCollector returns a new Collector exposing network device stats.
func NewNetDevCollector(logger *slog.Logger) (Collector, error) {
if *oldNetdevDeviceInclude != "" {
if *netdevDeviceInclude == "" {
logger.Warn("--collector.netdev.device-whitelist is DEPRECATED and will be removed in 2.0.0, use --collector.netdev.device-include")
*netdevDeviceInclude = *oldNetdevDeviceInclude
} else {
return nil, errors.New("--collector.netdev.device-whitelist and --collector.netdev.device-include are mutually exclusive")
}
}

if *oldNetdevDeviceExclude != "" {
if *netdevDeviceExclude == "" {
logger.Warn("--collector.netdev.device-blacklist is DEPRECATED and will be removed in 2.0.0, use --collector.netdev.device-exclude")
*netdevDeviceExclude = *oldNetdevDeviceExclude
} else {
return nil, errors.New("--collector.netdev.device-blacklist and --collector.netdev.device-exclude are mutually exclusive")
}
}

if *netdevDeviceExclude != "" && *netdevDeviceInclude != "" {
return nil, errors.New("device-exclude & device-include are mutually exclusive")
}
Expand Down
177 changes: 0 additions & 177 deletions collector/ntp.go

This file was deleted.

26 changes: 3 additions & 23 deletions collector/qdisc_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ type qdiscStatCollector struct {
}

var (
collectorQdisc = kingpin.Flag("collector.qdisc.fixtures", "test fixtures to use for qdisc collector end-to-end testing").Default("").String()
collectorQdiscDeviceInclude = kingpin.Flag("collector.qdisc.device-include", "Regexp of qdisc devices to include (mutually exclusive to device-exclude).").String()
oldCollectorQdiskDeviceInclude = kingpin.Flag("collector.qdisk.device-include", "DEPRECATED: Use collector.qdisc.device-include").Hidden().String()
collectorQdiscDeviceExclude = kingpin.Flag("collector.qdisc.device-exclude", "Regexp of qdisc devices to exclude (mutually exclusive to device-include).").String()
oldCollectorQdiskDeviceExclude = kingpin.Flag("collector.qdisk.device-exclude", "DEPRECATED: Use collector.qdisc.device-exclude").Hidden().String()
collectorQdisc = kingpin.Flag("collector.qdisc.fixtures", "test fixtures to use for qdisc collector end-to-end testing").Default("").String()
collectorQdiscDeviceInclude = kingpin.Flag("collector.qdisc.device-include", "Regexp of qdisc devices to include (mutually exclusive to device-exclude).").String()
collectorQdiscDeviceExclude = kingpin.Flag("collector.qdisc.device-exclude", "Regexp of qdisc devices to exclude (mutually exclusive to device-include).").String()
)

func init() {
Expand All @@ -54,24 +52,6 @@ func init() {

// NewQdiscStatCollector returns a new Collector exposing queuing discipline statistics.
func NewQdiscStatCollector(logger *slog.Logger) (Collector, error) {
if *oldCollectorQdiskDeviceInclude != "" {
if *collectorQdiscDeviceInclude == "" {
logger.Warn("--collector.qdisk.device-include is DEPRECATED and will be removed in 2.0.0, use --collector.qdisc.device-include")
*collectorQdiscDeviceInclude = *oldCollectorQdiskDeviceInclude
} else {
return nil, fmt.Errorf("--collector.qdisk.device-include and --collector.qdisc.device-include are mutually exclusive")
}
}

if *oldCollectorQdiskDeviceExclude != "" {
if *collectorQdiscDeviceExclude == "" {
logger.Warn("--collector.qdisk.device-exclude is DEPRECATED and will be removed in 2.0.0, use --collector.qdisc.device-exclude")
*collectorQdiscDeviceExclude = *oldCollectorQdiskDeviceExclude
} else {
return nil, fmt.Errorf("--collector.qdisk.device-exclude and --collector.qdisc.device-exclude are mutually exclusive")
}
}

if *collectorQdiscDeviceExclude != "" && *collectorQdiscDeviceInclude != "" {
return nil, fmt.Errorf("collector.qdisc.device-include and collector.qdisc.device-exclude are mutaly exclusive")
}
Expand Down
2 changes: 1 addition & 1 deletion collector/rapl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func init() {
}

var (
raplZoneLabel = kingpin.Flag("collector.rapl.enable-zone-label", "Enables service unit metric unit_start_time_seconds").Bool()
raplZoneLabel = kingpin.Flag("collector.rapl.enable-zone-label", "Enables service unit metric unit_start_time_seconds").Default("true").Bool()
)

// NewRaplCollector returns a new Collector exposing RAPL metrics.
Expand Down
Loading

0 comments on commit 6378027

Please sign in to comment.