package metrics import "github.com/prometheus/client_golang/prometheus" // Option is the functional interface that is used to provide public options for // creating metrics structs. type Option func(*options) // WithCollectors adds custom collectors in addition to the built in controller // metrics. func WithCollectors(c ...prometheus.Collector) Option { return func(o *options) { o.customCollectors = c } } // WithSuspend adds a collector for recording an objects suspension status via // Metrics.RecordSuspend() func WithSuspend() Option { return func(o *options) { o.suspend = true } } // WithReason adds the `reason` label to the reconcile_condition_status gauge func WithReason() Option { return func(o *options) { o.reason = true } } type options struct { // whether or not to add the gauge for recording object suspension suspend bool // whether or not to use the `reason` label in reconcile_condition_status reason bool customCollectors []prometheus.Collector } func makeOptions(opts ...Option) *options { o := &options{customCollectors: []prometheus.Collector{}} for _, opt := range opts { opt(o) } return o }