Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Allow users to create custom registries #2672

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/internal/controller/metrics/metrics.go
Expand Up @@ -84,3 +84,15 @@ func init() {
collectors.NewGoCollector(),
)
}

// register the metrics with the passed registry
func RegisterReconciliationMetrics(customRegistry metrics.RegistererGatherer) {
customRegistry.MustRegister(
ReconcileTotal,
ReconcileErrors,
TerminalReconcileErrors,
ReconcileTime,
WorkerCount,
ActiveWorkers,
)
}
5 changes: 5 additions & 0 deletions pkg/metrics/client_go_adapter.go
Expand Up @@ -43,6 +43,11 @@ func init() {
registerClientMetrics()
}

// register the metrics with the passed registry
func RegisterClientMetrics(customRegistry RegistererGatherer) {
customRegistry.MustRegister(requestResult)
}

// registerClientMetrics sets up the client latency metrics from client-go.
func registerClientMetrics() {
// register the metrics with our registry
Expand Down
5 changes: 5 additions & 0 deletions pkg/metrics/leaderelection.go
Expand Up @@ -21,6 +21,11 @@ func init() {
leaderelection.SetProvider(leaderelectionMetricsProvider{})
}

// register the metrics with the passed registry
func RegisterLeaderElection(customRegistry RegistererGatherer) {
customRegistry.MustRegister(leaderGauge)
}

type leaderelectionMetricsProvider struct{}

func (leaderelectionMetricsProvider) NewLeaderMetric() leaderelection.SwitchMetric {
Expand Down
13 changes: 13 additions & 0 deletions pkg/metrics/workqueue.go
Expand Up @@ -99,6 +99,19 @@ func init() {
workqueue.SetProvider(workqueueMetricsProvider{})
}

// register the metrics with the passed registry
func RegisterWorkqueueMetrics(customRegistry RegistererGatherer) {
customRegistry.MustRegister(
depth,
adds,
latency,
workDuration,
unfinished,
longestRunningProcessor,
retries,
)
}

type workqueueMetricsProvider struct{}

func (workqueueMetricsProvider) NewDepthMetric(name string) workqueue.GaugeMetric {
Expand Down
9 changes: 9 additions & 0 deletions pkg/webhook/internal/metrics/metrics.go
Expand Up @@ -63,6 +63,15 @@ func init() {
metrics.Registry.MustRegister(RequestLatency, RequestTotal, RequestInFlight)
}

// register the metrics with the passed registry
func RegisterRequestMetrics(customRegistry metrics.RegistererGatherer) {
customRegistry.MustRegister(
RequestLatency,
RequestTotal,
RequestInFlight,
)
}

// InstrumentedHook adds some instrumentation on top of the given webhook.
func InstrumentedHook(path string, hookRaw http.Handler) http.Handler {
lbl := prometheus.Labels{"webhook": path}
Expand Down