aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremaclee <lee.anjella.macabuhay@est.tech>2025-01-21 11:16:04 +0000
committeremaclee <lee.anjella.macabuhay@est.tech>2025-01-22 06:19:25 +0000
commit33caaf123bd285237d28c12fbf54de212bfcda55 (patch)
tree92be7b2984853d1a1bb66a33f5a909c23c772b4c
parent6fb1e85fd1cdb20cb8f64f81c188c29c0391ab2a (diff)
Add 'Deleted' cm handle state for gauge
Issue-ID: CPS-2456 Change-Id: I2f7ff2dd18d164dbf685269fb2d2e47d08c3c5f5 Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
-rw-r--r--cps-application/src/main/java/org/onap/cps/config/MicroMeterConfig.java23
-rw-r--r--cps-application/src/test/groovy/org/onap/cps/config/MicroMeterConfigSpec.groovy3
2 files changed, 21 insertions, 5 deletions
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
}