Skip to content

Commit

Permalink
Remove unused OptIn collector catagory
Browse files Browse the repository at this point in the history
  • Loading branch information
nocturnalastro committed Oct 9, 2023
1 parent 4963c60 commit 128781e
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 25 deletions.
6 changes: 2 additions & 4 deletions pkg/cmd/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func init() { //nolint:funlen // Allow this to get a little long
"interval at which to emit the device info summary to the targeted output.",
)
defaultCollectorNames := make([]string, 0)
defaultCollectorNames = append(defaultCollectorNames, runner.Default)
defaultCollectorNames = append(defaultCollectorNames, runner.All)
collectCmd.Flags().StringSliceVarP(
&collectorNames,
"collector",
Expand All @@ -135,11 +135,9 @@ func init() { //nolint:funlen // Allow this to get a little long
fmt.Sprintf(
"the collectors you wish to run (case-insensitive):\n"+
"\trequired collectors: %s (will be automatically added)\n"+
"\toptional collectors: %s\n"+
"\topt in collectors: %s (note: these are not included by default)",
"\toptional collectors: %s",
strings.Join(runner.RequiredCollectorNames, ", "),
strings.Join(runner.OptionalCollectorNames, ", "),
strings.Join(runner.OptInCollectorNames, ", "),
),
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/collectors/dpll_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,5 @@ func NewDPLLCollector(constructor *CollectionConstructor) (Collector, error) {
}

func init() {
RegisterCollector(DPLLCollectorName, NewDPLLCollector, includeByDefault)
RegisterCollector(DPLLCollectorName, NewDPLLCollector, optional)
}
2 changes: 1 addition & 1 deletion pkg/collectors/gps_ubx_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ func NewGPSCollector(constructor *CollectionConstructor) (Collector, error) {
}

func init() {
RegisterCollector(GPSCollectorName, NewGPSCollector, includeByDefault)
RegisterCollector(GPSCollectorName, NewGPSCollector, optional)
}
2 changes: 1 addition & 1 deletion pkg/collectors/log_follower.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,5 @@ func NewLogsCollector(constructor *CollectionConstructor) (Collector, error) {

func init() {
// Make log opt in as in may lose some data.
RegisterCollector(LogsCollectorName, NewLogsCollector, includeByDefault)
RegisterCollector(LogsCollectorName, NewLogsCollector, optional)
}
2 changes: 1 addition & 1 deletion pkg/collectors/pmc_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ func NewPMCCollector(constructor *CollectionConstructor) (Collector, error) {
}

func init() {
RegisterCollector(PMCCollectorName, NewPMCCollector, includeByDefault)
RegisterCollector(PMCCollectorName, NewPMCCollector, optional)
}
13 changes: 2 additions & 11 deletions pkg/collectors/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ type collectorInclusionType int

const (
required collectorInclusionType = iota
includeByDefault
optIn
optional
)

type CollectorRegistry struct {
registry map[string]collectonBuilderFunc
required []string
optional []string
optIn []string
}

var registry *CollectorRegistry
Expand All @@ -38,10 +36,8 @@ func (reg *CollectorRegistry) register(
switch inclusionType {
case required:
reg.required = append(reg.required, collectorName)
case includeByDefault:
case optional:
reg.optional = append(reg.optional, collectorName)
case optIn:
reg.optIn = append(reg.optIn, collectorName)
default:
log.Panic("Incorrect collector inclusion type")
}
Expand All @@ -63,17 +59,12 @@ func (reg *CollectorRegistry) GetOptionalNames() []string {
return reg.optional
}

func (reg *CollectorRegistry) GetOptInNames() []string {
return reg.optIn
}

func RegisterCollector(collectorName string, builderFunc collectonBuilderFunc, inclusionType collectorInclusionType) {
if registry == nil {
registry = &CollectorRegistry{
registry: make(map[string]collectonBuilderFunc, 0),
required: make([]string, 0),
optional: make([]string, 0),
optIn: make([]string, 0),
}
}
registry.register(collectorName, builderFunc, inclusionType)
Expand Down
6 changes: 0 additions & 6 deletions pkg/runner/collector_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ import (
var (
OptionalCollectorNames []string
RequiredCollectorNames []string
OptInCollectorNames []string
Default string = "defaults"
All string = "all"
)

func init() {
registry := collectors.GetRegistry()
OptionalCollectorNames = registry.GetOptionalNames()
RequiredCollectorNames = registry.GetRequiredNames()
OptInCollectorNames = registry.GetOptInNames()
}

func isIn(name string, arr []string) bool {
Expand Down Expand Up @@ -54,15 +51,12 @@ func GetCollectorsToRun(selectedCollectors []string) []string {
switch {
case strings.EqualFold(name, "all"):
collectorNames = append(collectorNames, OptionalCollectorNames...)
collectorNames = append(collectorNames, OptInCollectorNames...)
case strings.EqualFold(name, "defaults"):
collectorNames = append(collectorNames, OptionalCollectorNames...)
case isIn(name, collectorNames):
continue
case isIn(name, OptionalCollectorNames):
collectorNames = append(collectorNames, name)
case isIn(name, OptInCollectorNames):
collectorNames = append(collectorNames, name)
default:
log.Errorf("Unknown collector %s. Ignored", name)
}
Expand Down

0 comments on commit 128781e

Please sign in to comment.