Skip to content

Commit

Permalink
fix(qdisc) flag naming corrected for consistency (#2782)
Browse files Browse the repository at this point in the history
* fix collector qdisc flag naming for consistency

---------

Signed-off-by: jbradleynh <jbradley@fastly.com>
  • Loading branch information
jbradleynh authored Aug 21, 2023
1 parent e120d95 commit f2b2743
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
33 changes: 27 additions & 6 deletions collector/qdisc_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/alecthomas/kingpin/v2"
"github.com/ema/qdisc"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
)

Expand All @@ -41,9 +42,11 @@ type qdiscStatCollector struct {
}

var (
collectorQdisc = kingpin.Flag("collector.qdisc.fixtures", "test fixtures to use for qdisc collector end-to-end testing").Default("").String()
collectorQdiskDeviceInclude = kingpin.Flag("collector.qdisk.device-include", "Regexp of qdisk devices to include (mutually exclusive to device-exclude).").String()
collectorQdiskDeviceExclude = kingpin.Flag("collector.qdisk.device-exclude", "Regexp of qdisk devices to exclude (mutually exclusive to device-include).").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()
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()
)

func init() {
Expand All @@ -52,8 +55,26 @@ func init() {

// NewQdiscStatCollector returns a new Collector exposing queuing discipline statistics.
func NewQdiscStatCollector(logger log.Logger) (Collector, error) {
if *collectorQdiskDeviceExclude != "" && *collectorQdiskDeviceInclude != "" {
return nil, fmt.Errorf("collector.qdisk.device-include and collector.qdisk.device-exclude are mutaly exclusive")
if *oldCollectorQdiskDeviceInclude != "" {
if *collectorQdiscDeviceInclude == "" {
level.Warn(logger).Log("msg", "--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 == "" {
level.Warn(logger).Log("msg", "--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")
}

return &qdiscStatCollector{
Expand Down Expand Up @@ -93,7 +114,7 @@ func NewQdiscStatCollector(logger log.Logger) (Collector, error) {
[]string{"device", "kind"}, nil,
), prometheus.GaugeValue},
logger: logger,
deviceFilter: newDeviceFilter(*collectorQdiskDeviceExclude, *collectorQdiskDeviceExclude),
deviceFilter: newDeviceFilter(*collectorQdiscDeviceExclude, *collectorQdiscDeviceInclude),
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion end-to-end-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fi
--collector.textfile.directory="collector/fixtures/textfile/two_metric_files/" \
--collector.wifi.fixtures="collector/fixtures/wifi" \
--collector.qdisc.fixtures="collector/fixtures/qdisc/" \
--collector.qdisk.device-include="(wlan0|eth0)" \
--collector.qdisc.device-include="(wlan0|eth0)" \
--collector.arp.device-exclude="nope" \
--collector.hwmon.chip-include="(applesmc|coretemp|hwmon4|nct6779)" \
--collector.netclass.ignored-devices="(dmz|int)" \
Expand Down

0 comments on commit f2b2743

Please sign in to comment.