Add Prometheus metric messages for ACM runtime 36/130536/1
authorFrancescoFioraEst <francesco.fiora@est.tech>
Wed, 31 Aug 2022 09:38:10 +0000 (10:38 +0100)
committerFrancescoFioraEst <francesco.fiora@est.tech>
Wed, 31 Aug 2022 09:51:45 +0000 (10:51 +0100)
Issue-ID: POLICY-4336
Change-Id: I8f89f795625d8802ee6f3836c6fc4b66f0db75db
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionStateChangePublisher.java
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantDeregisterAckPublisher.java
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRegisterAckPublisher.java
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantStatusReqPublisher.java
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantUpdatePublisher.java

index dca31cd..084f7c7 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.onap.policy.clamp.acm.runtime.config;
 
+import io.micrometer.core.aop.TimedAspect;
 import io.micrometer.core.instrument.MeterRegistry;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.config.BeanPostProcessor;
@@ -33,8 +34,19 @@ public class MetricsConfiguration {
      * Load up the metrics registry.
      */
     @Bean
-    InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
-                                                  MeterRegistry registry) {
+    public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
+            MeterRegistry registry) {
         return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
     }
+
+    /**
+     * Register TimedAspect.
+     *
+     * @param registry MeterRegistry
+     * @return TimedAspect
+     */
+    @Bean
+    public TimedAspect timedAspect(MeterRegistry registry) {
+        return new TimedAspect(registry);
+    }
 }
index 055acb2..6591655 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021 Nordix Foundation.
+ *  Copyright (C) 2021,2022 Nordix Foundation.
  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
 
 package org.onap.policy.clamp.acm.runtime.supervision;
 
+import io.micrometer.core.annotation.Timed;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -135,6 +136,7 @@ public class SupervisionHandler {
      * @param participantStatusMessage the ParticipantStatus message received from a participant
      */
     @MessageIntercept
+    @Timed(value = "listener.participant_status", description = "PARTICIPANT_STATUS messages received")
     public void handleParticipantMessage(ParticipantStatus participantStatusMessage) {
         LOGGER.debug("Participant Status received {}", participantStatusMessage);
         try {
@@ -157,6 +159,7 @@ public class SupervisionHandler {
      * @param participantRegisterMessage the ParticipantRegister message received from a participant
      */
     @MessageIntercept
+    @Timed(value = "listener.participant_register", description = "PARTICIPANT_REGISTER messages received")
     public boolean handleParticipantMessage(ParticipantRegister participantRegisterMessage) {
         LOGGER.debug("Participant Register received {}", participantRegisterMessage);
         try {
@@ -179,6 +182,7 @@ public class SupervisionHandler {
      * @param participantDeregisterMessage the ParticipantDeregister message received from a participant
      */
     @MessageIntercept
+    @Timed(value = "listener.participant_deregister", description = "PARTICIPANT_DEREGISTER messages received")
     public void handleParticipantMessage(ParticipantDeregister participantDeregisterMessage) {
         LOGGER.debug("Participant Deregister received {}", participantDeregisterMessage);
         try {
@@ -206,6 +210,7 @@ public class SupervisionHandler {
      * @param participantUpdateAckMessage the ParticipantUpdateAck message received from a participant
      */
     @MessageIntercept
+    @Timed(value = "listener.participant_update_ack", description = "PARTICIPANT_UPDATE_ACK messages received")
     public void handleParticipantMessage(ParticipantUpdateAck participantUpdateAckMessage) {
         LOGGER.debug("Participant Update Ack received {}", participantUpdateAckMessage);
         try {
@@ -253,6 +258,8 @@ public class SupervisionHandler {
      * @param automationCompositionAckMessage the AutomationCompositionAck message received from a participant
      */
     @MessageIntercept
+    @Timed(value = "listener.automation_composition_update_ack",
+        description = "AUTOMATION_COMPOSITION_UPDATE_ACK messages received")
     public void handleAutomationCompositionUpdateAckMessage(AutomationCompositionAck automationCompositionAckMessage) {
         LOGGER.debug("AutomationComposition Update Ack message received {}", automationCompositionAckMessage);
         setAcElementStateInDb(automationCompositionAckMessage);
@@ -264,6 +271,8 @@ public class SupervisionHandler {
      * @param automationCompositionAckMessage the AutomationCompositionAck message received from a participant
      */
     @MessageIntercept
+    @Timed(value = "listener.automation_composition_statechange_ack",
+        description = "AUTOMATION_COMPOSITION_STATECHANGE_ACK messages received")
     public void handleAutomationCompositionStateChangeAckMessage(
         AutomationCompositionAck automationCompositionAckMessage) {
         LOGGER.debug("AutomationComposition StateChange Ack message received {}", automationCompositionAckMessage);
index 4e0d12b..79b8f90 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021,2022 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 package org.onap.policy.clamp.acm.runtime.supervision.comm;
 
+import io.micrometer.core.annotation.Timed;
 import java.util.UUID;
 import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
 import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange;
@@ -38,6 +39,8 @@ public class AutomationCompositionStateChangePublisher
      * @param automationComposition the AutomationComposition
      * @param startPhase the startPhase
      */
+    @Timed(value = "publisher.automation_composition_state_change",
+            description = "AUTOMATION_COMPOSITION_STATE_CHANGE messages published")
     public void send(AutomationComposition automationComposition, int startPhase) {
         var acsc = new AutomationCompositionStateChange();
         acsc.setAutomationCompositionId(automationComposition.getKey().asIdentifier());
index ac5a998..56da7e5 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021,2022 Nordix Foundation.
  * ================================================================================
  * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
@@ -22,6 +22,7 @@
 
 package org.onap.policy.clamp.acm.runtime.supervision.comm;
 
+import io.micrometer.core.annotation.Timed;
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.List;
@@ -54,6 +55,8 @@ public class AutomationCompositionUpdatePublisher extends AbstractParticipantPub
      *
      * @param automationComposition the AutomationComposition
      */
+    @Timed(value = "publisher.automation_composition_update",
+            description = "AUTOMATION_COMPOSITION_UPDATE messages published")
     public void send(AutomationComposition automationComposition) {
         send(automationComposition, 0);
     }
@@ -64,6 +67,8 @@ public class AutomationCompositionUpdatePublisher extends AbstractParticipantPub
      * @param automationComposition the AutomationComposition
      * @param startPhase the Start Phase
      */
+    @Timed(value = "publisher.automation_composition_update",
+            description = "AUTOMATION_COMPOSITION_UPDATE messages published")
     public void send(AutomationComposition automationComposition, int startPhase) {
         var automationCompositionUpdateMsg = new AutomationCompositionUpdate();
         automationCompositionUpdateMsg.setStartPhase(startPhase);
index 34881b5..1b2edf7 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021,2022 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 package org.onap.policy.clamp.acm.runtime.supervision.comm;
 
+import io.micrometer.core.annotation.Timed;
 import java.util.UUID;
 import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck;
 import org.springframework.stereotype.Component;
@@ -35,6 +36,8 @@ public class ParticipantDeregisterAckPublisher extends AbstractParticipantAckPub
      *
      * @param responseTo the original request id in the request.
      */
+    @Timed(value = "publisher.participant_deregister_ack",
+            description = "PARTICIPANT_DEREGISTER_ACK messages published")
     public void send(UUID responseTo) {
         var message = new ParticipantDeregisterAck();
         message.setResponseTo(responseTo);
index 8344837..bd8f2b5 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021,2022 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 package org.onap.policy.clamp.acm.runtime.supervision.comm;
 
+import io.micrometer.core.annotation.Timed;
 import java.util.UUID;
 import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -38,6 +39,7 @@ public class ParticipantRegisterAckPublisher extends AbstractParticipantAckPubli
      * @param participantId the participant Id
      * @param participantType the participant Type
      */
+    @Timed(value = "publisher.participant_register_ack", description = "PARTICIPANT_REGISTER_ACK messages published")
     public void send(UUID responseTo, ToscaConceptIdentifier participantId, ToscaConceptIdentifier participantType) {
         var message = new ParticipantRegisterAck();
         message.setParticipantId(participantId);
index 0de8ff0..d1f183e 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021 Nordix Foundation.
+ *  Copyright (C) 2021,2022 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 package org.onap.policy.clamp.acm.runtime.supervision.comm;
 
+import io.micrometer.core.annotation.Timed;
 import java.time.Instant;
 import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -37,6 +38,7 @@ public class ParticipantStatusReqPublisher extends AbstractParticipantPublisher<
      *
      * @param participantId the participant Id
      */
+    @Timed(value = "publisher.participant_status_req", description = "PARTICIPANT_STATUS_REQ messages published")
     public void send(ToscaConceptIdentifier participantId) {
         ParticipantStatusReq message = new ParticipantStatusReq();
         message.setParticipantId(participantId);
index 47a66c1..27e8156 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021,2022 Nordix Foundation.
  * ================================================================================
  * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
@@ -22,6 +22,7 @@
 
 package org.onap.policy.clamp.acm.runtime.supervision.comm;
 
+import io.micrometer.core.annotation.Timed;
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.List;
@@ -57,6 +58,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
      * @param name the ToscaServiceTemplate name
      * @param version the ToscaServiceTemplate version
      */
+    @Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
     public void sendComissioningBroadcast(String name, String version) {
         sendCommissioning(name, version, null, null);
     }
@@ -70,6 +72,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
      * @param participantType the ParticipantType
      * @param participantId the ParticipantId
      */
+    @Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
     public boolean sendCommissioning(String name, String version, ToscaConceptIdentifier participantType,
             ToscaConceptIdentifier participantId) {
         var message = new ParticipantUpdate();
@@ -115,6 +118,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
     /**
      * Send ParticipantUpdate to Participant after that commissioning has been removed.
      */
+    @Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
     public void sendDecomisioning() {
         var message = new ParticipantUpdate();
         message.setTimestamp(Instant.now());