prometheus / exporter-toolkit

Utility package to build exporters
Apache License 2.0
261 stars 79 forks source link

feat: function `exporter-toolkit/web/kingpinflag.AddFlags` and `common/promlog/flag.AddFlags` support `kingpin.CmdClause` as argument #234

Closed fengxsong closed 1 week ago

fengxsong commented 1 month ago

Currently those two functions only accept *kingpin.Application as the first argument, When we use these methods in subcommands, we must wrap them again instead of calling them directly. here's a proposal

type flagGroup interface {
    Flag(string, string) *kingpin.FlagClause
}

func AddFlags(a flagGroup, defaultAddress string) *web.FlagConfig ...

func AddFlags(a flagGroup, config *promlog.Config) ...

This change won't impact existing method calls and ensures compatibility.

metalmatze commented 2 weeks ago

It's probably easiest if you send a PR directly. Thanks!