diff --git a/injection/sharedmain/main.go b/injection/sharedmain/main.go index 25562e965e..79c42c2014 100644 --- a/injection/sharedmain/main.go +++ b/injection/sharedmain/main.go @@ -290,7 +290,12 @@ func MainWithConfig(ctx context.Context, component string, cfg *rest.Config, cto var wh *webhook.Webhook if len(webhooks) > 0 { // Register webhook metrics - webhook.RegisterMetrics() + opts := webhook.GetOptions(ctx) + if opts != nil { + webhook.RegisterMetrics(opts.StatsReporterOptions...) + } else { + webhook.RegisterMetrics() + } wh, err = webhook.New(ctx, webhooks) if err != nil { diff --git a/webhook/webhook.go b/webhook/webhook.go index eff693e80d..d8842df35a 100644 --- a/webhook/webhook.go +++ b/webhook/webhook.go @@ -70,6 +70,9 @@ type Options struct { // only a single port for the service. Port int + // StatsReporterOptions are the options used to initialize the default StatsReporter + StatsReporterOptions []StatsReporterOption + // StatsReporter reports metrics about the webhook. // This will be automatically initialized by the constructor if left uninitialized. StatsReporter StatsReporter @@ -144,7 +147,7 @@ func New( logger := logging.FromContext(ctx) if opts.StatsReporter == nil { - reporter, err := NewStatsReporter() + reporter, err := NewStatsReporter(opts.StatsReporterOptions...) if err != nil { return nil, err }