Skip to content

Commit

Permalink
add --collector.netframework.enabled CLI flag
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Jan 15, 2025
1 parent 86e6d12 commit 61eb927
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions internal/collector/netframework/netframework.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"log/slog"
"sort"
"strings"
"sync"

"github.com/alecthomas/kingpin/v2"
Expand Down Expand Up @@ -143,8 +144,26 @@ func New(config *Config) *Collector {
return c
}

func NewWithFlags(_ *kingpin.Application) *Collector {
return &Collector{}
func NewWithFlags(app *kingpin.Application) *Collector {
c := &Collector{
config: ConfigDefaults,
}
c.config.CollectorsEnabled = make([]string, 0)

var collectorsEnabled string

app.Flag(
"collector.netframework.enabled",
"Comma-separated list of collectors to use. Defaults to all, if not specified.",
).Default(strings.Join(ConfigDefaults.CollectorsEnabled, ",")).StringVar(&collectorsEnabled)

app.Action(func(*kingpin.ParseContext) error {
c.config.CollectorsEnabled = strings.Split(collectorsEnabled, ",")

return nil
})

return c
}

func (c *Collector) GetName() string {
Expand Down

0 comments on commit 61eb927

Please sign in to comment.