From 6e6e1566598e0748d7e6965f61f5cf4cdf34cd71 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Tue, 19 Sep 2023 11:32:48 -0400 Subject: [PATCH] Reinstate the submariner_service_export metric This got lost in the shuffle during during the refactoring in the 0.15 release. Fixes https://github.com/submariner-io/lighthouse/issues/1363 Signed-off-by: Tom Pantelis --- pkg/agent/controller/service_import.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/pkg/agent/controller/service_import.go b/pkg/agent/controller/service_import.go index cba5f80d1..dd4675ee9 100644 --- a/pkg/agent/controller/service_import.go +++ b/pkg/agent/controller/service_import.go @@ -56,19 +56,6 @@ func newServiceImportController(spec *AgentSpecification, syncerMetricNames Agen serviceExportClient: serviceExportClient, } - syncCounter := prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Name: syncerMetricNames.ServiceImportCounterName, - Help: "Count of imported services", - }, - []string{ - syncer.DirectionLabel, - syncer.OperationLabel, - syncer.SyncerNameLabel, - }, - ) - prometheus.MustRegister(syncCounter) - var err error controller.localSyncer, err = syncer.NewResourceSyncer(&syncer.ResourceSyncerConfig{ @@ -81,7 +68,10 @@ func newServiceImportController(spec *AgentSpecification, syncerMetricNames Agen ResourceType: &mcsv1a1.ServiceImport{}, Transform: controller.onLocalServiceImport, Scheme: syncerConfig.Scheme, - SyncCounter: syncCounter, + SyncCounterOpts: &prometheus.GaugeOpts{ + Name: syncerMetricNames.ServiceExportCounterName, + Help: "Count of exported services", + }, }) if err != nil { return nil, errors.Wrap(err, "error creating local ServiceImport syncer") @@ -107,6 +97,10 @@ func newServiceImportController(spec *AgentSpecification, syncerMetricNames Agen OnSuccessfulSync: controller.serviceImportMigrator.onSuccessfulSyncFromBroker, Scheme: syncerConfig.Scheme, ResyncPeriod: brokerResyncePeriod, + SyncCounterOpts: &prometheus.GaugeOpts{ + Name: syncerMetricNames.ServiceImportCounterName, + Help: "Count of imported services", + }, }) if err != nil { return nil, errors.Wrap(err, "error creating ServiceImport watcher")