From 7396ddccd7609d7b762026ad8ab01bc41d037b99 Mon Sep 17 00:00:00 2001 From: williamlardier Date: Thu, 19 Sep 2024 11:52:05 +0200 Subject: [PATCH] Rename metric to avoid unnecessary name - also fix a comment Issue: BB-601 --- extensions/oplogPopulator/OplogPopulator.js | 2 +- extensions/oplogPopulator/OplogPopulatorMetrics.js | 4 ++-- .../allocationStrategy/RetainBucketsDecorator.js | 2 +- extensions/oplogPopulator/constants.js | 1 + extensions/oplogPopulator/modules/ConnectorsManager.js | 2 +- tests/unit/oplogPopulator/oplogPopulator.js | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/extensions/oplogPopulator/OplogPopulator.js b/extensions/oplogPopulator/OplogPopulator.js index 19cefd7e9..cd4affb9b 100644 --- a/extensions/oplogPopulator/OplogPopulator.js +++ b/extensions/oplogPopulator/OplogPopulator.js @@ -291,7 +291,7 @@ class OplogPopulator { this._allocationStrategy.onConnectorUpdatedOrDestroyed(connector)); this._allocator.on(constants.bucketRemovedFromConnectorEvent, (bucket, connector) => this._allocationStrategy.onBucketRemoved(bucket, connector)); - this._connectorsManager.on('connectors-reconciled', bucketsExceedingLimit => { + this._connectorsManager.on(constants.connectorsReconciledEvent, bucketsExceedingLimit => { this._metricsHandler.onConnectorsReconciled( bucketsExceedingLimit, this._allocationStrategy.retainedBucketsCount, diff --git a/extensions/oplogPopulator/OplogPopulatorMetrics.js b/extensions/oplogPopulator/OplogPopulatorMetrics.js index f732a6325..4fe15cf90 100644 --- a/extensions/oplogPopulator/OplogPopulatorMetrics.js +++ b/extensions/oplogPopulator/OplogPopulatorMetrics.js @@ -34,11 +34,11 @@ class OplogPopulatorMetrics { labelNames: ['connector'], }); this.bucketsExceedingLimit = ZenkoMetrics.createGauge({ - name: 's3_oplog_populator_connector_buckets_exceeding_limit', + name: 's3_oplog_populator_buckets_exceeding_limit', help: 'Total number of buckets exceeding the limit for all connectors', }); this.retainedBuckets = ZenkoMetrics.createGauge({ - name: 's3_oplog_populator_connector_retained_buckets', + name: 's3_oplog_populator_retained_buckets', help: 'Current number of buckets still listened to by immutable connectors despite intended removal', }); this.requestSize = ZenkoMetrics.createCounter({ diff --git a/extensions/oplogPopulator/allocationStrategy/RetainBucketsDecorator.js b/extensions/oplogPopulator/allocationStrategy/RetainBucketsDecorator.js index 5d31e0258..040980b81 100644 --- a/extensions/oplogPopulator/allocationStrategy/RetainBucketsDecorator.js +++ b/extensions/oplogPopulator/allocationStrategy/RetainBucketsDecorator.js @@ -18,7 +18,7 @@ class RetainBucketsDecorator extends AllocationStrategy { super(params); this._strategy = strategy; - // Stores buckets that should are removed from the connector + // Stores buckets that should be removed from the connector // but still in use this._retainedBuckets = new Map(); } diff --git a/extensions/oplogPopulator/constants.js b/extensions/oplogPopulator/constants.js index b397a4424..5df585267 100644 --- a/extensions/oplogPopulator/constants.js +++ b/extensions/oplogPopulator/constants.js @@ -8,6 +8,7 @@ const constants = { mongodbVersionWithImmutablePipelines: '6.0.0', connectorUpdatedEvent: 'connector-updated', bucketRemovedFromConnectorEvent: 'bucket-removed', + connectorsReconciledEvent: 'connectors-reconciled', defaultConnectorConfig: { 'connector.class': 'com.mongodb.kafka.connect.MongoSourceConnector', 'pipeline': '[]', diff --git a/extensions/oplogPopulator/modules/ConnectorsManager.js b/extensions/oplogPopulator/modules/ConnectorsManager.js index 1ce7e2732..542c3e3f9 100644 --- a/extensions/oplogPopulator/modules/ConnectorsManager.js +++ b/extensions/oplogPopulator/modules/ConnectorsManager.js @@ -317,7 +317,7 @@ class ConnectorsManager extends EventEmitter { }); } }); - this.emit('connectors-reconciled', bucketsExceedingLimit); + this.emit(constants.connectorsReconciledEvent, bucketsExceedingLimit); if (Object.keys(connectorsStatus).length > 0) { this._logger.info('Successfully updated connectors', { method: 'ConnectorsManager._updateConnectors', diff --git a/tests/unit/oplogPopulator/oplogPopulator.js b/tests/unit/oplogPopulator/oplogPopulator.js index 30991a977..e6365b801 100644 --- a/tests/unit/oplogPopulator/oplogPopulator.js +++ b/tests/unit/oplogPopulator/oplogPopulator.js @@ -240,7 +240,7 @@ describe('OplogPopulator', () => { assert(setMetastoreChangeStreamStub.calledOnce); assert(initializeConnectorsManagerStub.calledOnce); const onConnectorsReconciledStub = sinon.stub(oplogPopulator._metricsHandler, 'onConnectorsReconciled'); - oplogPopulator._connectorsManager.emit('connectors-reconciled'); + oplogPopulator._connectorsManager.emit(constants.connectorsReconciledEvent); assert(onConnectorsReconciledStub.calledOnce); }); });