Replace --collectors.enabled with per-collector flags (#640)

* Move NodeCollector into package collector

* Refactor collector enabling

* Update README with new collector enabled flags

* Fix out-of-date inline flag reference syntax

* Use new flags in end-to-end tests

* Add flag to disable all default collectors

* Track if a flag has been set explicitly

* Add --collectors.disable-defaults to README

* Revert disable-defaults flag

* Shorten flags

* Fixup timex collector registration

* Fix end-to-end tests

* Change procfs and sysfs path flags

* Fix review comments
This commit is contained in:
Calle Pettersson 2017-09-28 15:06:26 +02:00 committed by Johannes 'fish' Ziemke
commit 859a825bb8
58 changed files with 410 additions and 406 deletions

View file

@ -41,11 +41,11 @@ type wifiCollector struct {
}
var (
collectorWifi = kingpin.Flag("collector.wifi", "test fixtures to use for wifi collector metrics").Default("").String()
collectorWifi = kingpin.Flag("collector.wifi.fixtures", "test fixtures to use for wifi collector metrics").Default("").String()
)
func init() {
Factories["wifi"] = NewWifiCollector
registerCollector("wifi", defaultEnabled, NewWifiCollector)
}
var _ wifiStater = &wifi.Client{}
@ -70,70 +70,70 @@ func NewWifiCollector() (Collector, error) {
return &wifiCollector{
interfaceFrequencyHertz: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "interface_frequency_hertz"),
prometheus.BuildFQName(namespace, subsystem, "interface_frequency_hertz"),
"The current frequency a WiFi interface is operating at, in hertz.",
labels,
nil,
),
stationInfo: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "station_info"),
prometheus.BuildFQName(namespace, subsystem, "station_info"),
"Labeled WiFi interface station information as provided by the operating system.",
[]string{"device", "bssid", "ssid", "mode"},
nil,
),
stationConnectedSecondsTotal: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "station_connected_seconds_total"),
prometheus.BuildFQName(namespace, subsystem, "station_connected_seconds_total"),
"The total number of seconds a station has been connected to an access point.",
labels,
nil,
),
stationInactiveSeconds: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "station_inactive_seconds"),
prometheus.BuildFQName(namespace, subsystem, "station_inactive_seconds"),
"The number of seconds since any wireless activity has occurred on a station.",
labels,
nil,
),
stationReceiveBitsPerSecond: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "station_receive_bits_per_second"),
prometheus.BuildFQName(namespace, subsystem, "station_receive_bits_per_second"),
"The current WiFi receive bitrate of a station, in bits per second.",
labels,
nil,
),
stationTransmitBitsPerSecond: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "station_transmit_bits_per_second"),
prometheus.BuildFQName(namespace, subsystem, "station_transmit_bits_per_second"),
"The current WiFi transmit bitrate of a station, in bits per second.",
labels,
nil,
),
stationSignalDBM: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "station_signal_dbm"),
prometheus.BuildFQName(namespace, subsystem, "station_signal_dbm"),
"The current WiFi signal strength, in decibel-milliwatts (dBm).",
labels,
nil,
),
stationTransmitRetriesTotal: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "station_transmit_retries_total"),
prometheus.BuildFQName(namespace, subsystem, "station_transmit_retries_total"),
"The total number of times a station has had to retry while sending a packet.",
labels,
nil,
),
stationTransmitFailedTotal: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "station_transmit_failed_total"),
prometheus.BuildFQName(namespace, subsystem, "station_transmit_failed_total"),
"The total number of times a station has failed to send a packet.",
labels,
nil,
),
stationBeaconLossTotal: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "station_beacon_loss_total"),
prometheus.BuildFQName(namespace, subsystem, "station_beacon_loss_total"),
"The total number of times a station has detected a beacon loss.",
labels,
nil,