From: emaclee Date: Tue, 21 Jan 2025 11:16:04 +0000 (+0000) Subject: Add 'Deleted' cm handle state for gauge X-Git-Tag: 3.6.0~19 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F71%2F139971%2F3;p=cps.git Add 'Deleted' cm handle state for gauge Issue-ID: CPS-2456 Change-Id: I2f7ff2dd18d164dbf685269fb2d2e47d08c3c5f5 Signed-off-by: emaclee --- diff --git a/cps-application/src/main/java/org/onap/cps/config/MicroMeterConfig.java b/cps-application/src/main/java/org/onap/cps/config/MicroMeterConfig.java index de981164f5..d169c61ad6 100644 --- a/cps-application/src/main/java/org/onap/cps/config/MicroMeterConfig.java +++ b/cps-application/src/main/java/org/onap/cps/config/MicroMeterConfig.java @@ -52,7 +52,7 @@ public class MicroMeterConfig { return Gauge.builder(CM_HANDLE_STATE_GAUGE, cmHandlesByState, value -> cmHandlesByState.get("advisedCmHandlesCount")) .tag(STATE_TAG, "ADVISED") - .description("Current number of cmhandles in advised state") + .description("Current number of cm handles in advised state") .register(meterRegistry); } @@ -67,7 +67,7 @@ public class MicroMeterConfig { return Gauge.builder(CM_HANDLE_STATE_GAUGE, cmHandlesByState, value -> cmHandlesByState.get("readyCmHandlesCount")) .tag(STATE_TAG, "READY") - .description("Current number of cmhandles in ready state") + .description("Current number of cm handles in ready state") .register(meterRegistry); } @@ -82,7 +82,7 @@ public class MicroMeterConfig { return Gauge.builder(CM_HANDLE_STATE_GAUGE, cmHandlesByState, value -> cmHandlesByState.get("lockedCmHandlesCount")) .tag(STATE_TAG, "LOCKED") - .description("Current number of cmhandles in locked state") + .description("Current number of cm handles in locked state") .register(meterRegistry); } @@ -97,7 +97,22 @@ public class MicroMeterConfig { return Gauge.builder(CM_HANDLE_STATE_GAUGE, cmHandlesByState, value -> cmHandlesByState.get("deletingCmHandlesCount")) .tag(STATE_TAG, "DELETING") - .description("Current number of cmhandles in deleting state") + .description("Current number of cm handles in deleting state") + .register(meterRegistry); + } + + /** + * Register gauge metric for cm handles with state 'deleted'. + * + * @param meterRegistry meter registry + * @return cm handle state gauge + */ + @Bean + public Gauge deletedCmHandles(final MeterRegistry meterRegistry) { + return Gauge.builder(CM_HANDLE_STATE_GAUGE, cmHandlesByState, + value -> cmHandlesByState.get("deletedCmHandlesCount")) + .tag(STATE_TAG, "DELETED") + .description("Number of cm handles that have been deleted since the application started") .register(meterRegistry); } diff --git a/cps-application/src/test/groovy/org/onap/cps/config/MicroMeterConfigSpec.groovy b/cps-application/src/test/groovy/org/onap/cps/config/MicroMeterConfigSpec.groovy index 9cef8de4b7..fc8c670ebf 100644 --- a/cps-application/src/test/groovy/org/onap/cps/config/MicroMeterConfigSpec.groovy +++ b/cps-application/src/test/groovy/org/onap/cps/config/MicroMeterConfigSpec.groovy @@ -43,8 +43,9 @@ class MicroMeterConfigSpec extends Specification { objectUnderTest.readyCmHandles(simpleMeterRegistry) objectUnderTest.lockedCmHandles(simpleMeterRegistry) objectUnderTest.deletingCmHandles(simpleMeterRegistry) + objectUnderTest.deletedCmHandles(simpleMeterRegistry) then: 'each state has the correct value when queried' - ['ADVISED', 'READY', 'LOCKED', 'DELETING'].each { state -> + ['ADVISED', 'READY', 'LOCKED', 'DELETING', 'DELETED'].each { state -> def gaugeValue = simpleMeterRegistry.get('cmHandlesByState').tag('state',state).gauge().value() assert gaugeValue == 1 }