Skip to content

Commit

Permalink
koord-manager: fix the prom metrics handler (#2107)
Browse files Browse the repository at this point in the history
Signed-off-by: saintube <saintube@foxmail.com>
  • Loading branch information
saintube committed Jun 25, 2024
1 parent ab5b62b commit 5e72bb1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/koord-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func main() {
mgrOpt.Cache.DefaultNamespaces[namespace] = cache.Config{}
}

installMetricsHandler(mgrOpt)
installMetricsHandler(&mgrOpt)
ctx := ctrl.SetupSignalHandler()

if utilfeature.DefaultFeatureGate.Enabled(features.WebhookFramework) {
Expand Down Expand Up @@ -207,11 +207,16 @@ func setRestConfig(c *rest.Config) {
}
}

func installMetricsHandler(mgr ctrl.Options) {
mgr.Metrics.ExtraHandlers = map[string]http.Handler{
func installMetricsHandler(mgr *ctrl.Options) {
if mgr.Metrics.ExtraHandlers == nil {
mgr.Metrics.ExtraHandlers = map[string]http.Handler{}
}
for path, handler := range map[string]http.Handler{
metrics.InternalHTTPPath: promhttp.HandlerFor(metrics.InternalRegistry, promhttp.HandlerOpts{}),
metrics.ExternalHTTPPath: promhttp.HandlerFor(metrics.ExternalRegistry, promhttp.HandlerOpts{}),
metrics.DefaultHTTPPath: promhttp.HandlerFor(
metricsutil.MergedGatherFunc(metrics.InternalRegistry, metrics.ExternalRegistry, ctrlmetrics.Registry), promhttp.HandlerOpts{}),
} {
mgr.Metrics.ExtraHandlers[path] = handler
}
}

0 comments on commit 5e72bb1

Please sign in to comment.