aboutsummaryrefslogtreecommitdiffstats
path: root/cps-application
diff options
context:
space:
mode:
authoremaclee <lee.anjella.macabuhay@est.tech>2025-01-12 12:39:55 +0000
committeremaclee <lee.anjella.macabuhay@est.tech>2025-01-16 15:28:15 +0000
commite0ea27a6e0902a4bff75ae5cd4b6025ee0d40a1c (patch)
tree80623f25990b8b2043c7e5690c1f96ba954da8a7 /cps-application
parentecfff5cb108e9679ee155a45becaa36a7e9c9059 (diff)
Handle restart case for cps-ncmp gauge metrics
Issue-ID: CPS-2456 Change-Id: I9ac5d6774fcd745d8141551eeff8a1deb1938f57 Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
Diffstat (limited to 'cps-application')
-rw-r--r--cps-application/src/main/java/org/onap/cps/config/MicroMeterConfig.java35
-rw-r--r--cps-application/src/test/groovy/org/onap/cps/config/MicroMeterConfigSpec.groovy3
2 files changed, 11 insertions, 27 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 39ed6ef5a7..de981164f5 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
@@ -32,8 +32,8 @@ import org.springframework.context.annotation.Configuration;
@RequiredArgsConstructor
public class MicroMeterConfig {
- private static final String TAG = "state";
- private static final String CMHANDLE_STATE_GAUGE = "cmHandlesByState";
+ private static final String STATE_TAG = "state";
+ private static final String CM_HANDLE_STATE_GAUGE = "cmHandlesByState";
final IMap<String, Integer> cmHandlesByState;
@Bean
@@ -49,9 +49,9 @@ public class MicroMeterConfig {
*/
@Bean
public Gauge advisedCmHandles(final MeterRegistry meterRegistry) {
- return Gauge.builder(CMHANDLE_STATE_GAUGE, cmHandlesByState,
+ return Gauge.builder(CM_HANDLE_STATE_GAUGE, cmHandlesByState,
value -> cmHandlesByState.get("advisedCmHandlesCount"))
- .tag(TAG, "ADVISED")
+ .tag(STATE_TAG, "ADVISED")
.description("Current number of cmhandles in advised state")
.register(meterRegistry);
}
@@ -64,9 +64,9 @@ public class MicroMeterConfig {
*/
@Bean
public Gauge readyCmHandles(final MeterRegistry meterRegistry) {
- return Gauge.builder(CMHANDLE_STATE_GAUGE, cmHandlesByState,
+ return Gauge.builder(CM_HANDLE_STATE_GAUGE, cmHandlesByState,
value -> cmHandlesByState.get("readyCmHandlesCount"))
- .tag(TAG, "READY")
+ .tag(STATE_TAG, "READY")
.description("Current number of cmhandles in ready state")
.register(meterRegistry);
}
@@ -79,9 +79,9 @@ public class MicroMeterConfig {
*/
@Bean
public Gauge lockedCmHandles(final MeterRegistry meterRegistry) {
- return Gauge.builder(CMHANDLE_STATE_GAUGE, cmHandlesByState,
+ return Gauge.builder(CM_HANDLE_STATE_GAUGE, cmHandlesByState,
value -> cmHandlesByState.get("lockedCmHandlesCount"))
- .tag(TAG, "LOCKED")
+ .tag(STATE_TAG, "LOCKED")
.description("Current number of cmhandles in locked state")
.register(meterRegistry);
}
@@ -94,26 +94,11 @@ public class MicroMeterConfig {
*/
@Bean
public Gauge deletingCmHandles(final MeterRegistry meterRegistry) {
- return Gauge.builder(CMHANDLE_STATE_GAUGE, cmHandlesByState,
+ return Gauge.builder(CM_HANDLE_STATE_GAUGE, cmHandlesByState,
value -> cmHandlesByState.get("deletingCmHandlesCount"))
- .tag(TAG, "DELETING")
+ .tag(STATE_TAG, "DELETING")
.description("Current number of cmhandles 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(CMHANDLE_STATE_GAUGE, cmHandlesByState,
- value -> cmHandlesByState.get("deletedCmHandlesCount"))
- .tag(TAG, "DELETED")
- .description("Current number of cmhandles in deleted state")
- .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 67ca64624a..da3afc6f2c 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,9 +43,8 @@ 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'
- def states = ["ADVISED", "READY", "LOCKED", "DELETING", "DELETED"]
+ def states = ["ADVISED", "READY", "LOCKED", "DELETING"]
states.each { state ->
def gaugeValue = simpleMeterRegistry.get("cmHandlesByState").tag("state",state).gauge().value()
assert gaugeValue == 1