summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java35
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageHandler.java8
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessagePublisher.java2
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ConfigService.java4
-rw-r--r--participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageHandlerTest.java4
-rw-r--r--participant/pom.xml5
6 files changed, 44 insertions, 14 deletions
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java
new file mode 100644
index 000000000..8e83a7739
--- /dev/null
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/config/MicrometerConfig.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.acm.element.config;
+
+import io.micrometer.core.aop.TimedAspect;
+import io.micrometer.core.instrument.MeterRegistry;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class MicrometerConfig {
+
+ @Bean
+ public TimedAspect timedAspect(MeterRegistry registry) {
+ return new TimedAspect(registry);
+ }
+}
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageHandler.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageHandler.java
index 63b0ebcfd..906fc321c 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageHandler.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessageHandler.java
@@ -20,12 +20,11 @@
package org.onap.policy.clamp.acm.element.handler;
-import java.util.ArrayList;
+import io.micrometer.core.annotation.Timed;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Response;
-import lombok.Getter;
import lombok.NonNull;
import org.onap.policy.clamp.acm.element.main.parameters.AcElement;
import org.onap.policy.clamp.acm.element.service.ElementService;
@@ -44,9 +43,6 @@ public class MessageHandler {
private Map<ElementType, ElementService> map = new HashMap<>();
- @Getter
- private List<ElementMessage> messages = new ArrayList<>();
-
/**
* Constructor.
*
@@ -99,8 +95,8 @@ public class MessageHandler {
return service;
}
+ @Timed(value = "listener.status", description = "STATUS messages received")
public void handleMessage(ElementMessage message) {
- messages.add(message);
getActiveService().handleMessage(message);
}
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessagePublisher.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessagePublisher.java
index 928a4fe04..1b0c2234a 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessagePublisher.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/handler/MessagePublisher.java
@@ -20,6 +20,7 @@
package org.onap.policy.clamp.acm.element.handler;
+import io.micrometer.core.annotation.Timed;
import java.util.List;
import javax.ws.rs.core.Response;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
@@ -56,6 +57,7 @@ public class MessagePublisher {
*
* @param msg the acknowledgement message
*/
+ @Timed(value = "publisher.status", description = "STATUS messages published")
public void publishMsg(final ElementMessage msg) {
if (!active) {
throw new AutomationCompositionRuntimeException(Response.Status.CONFLICT, NOT_ACTIVE_TEXT);
diff --git a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ConfigService.java b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ConfigService.java
index f8f9024f8..4ffed197c 100644
--- a/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ConfigService.java
+++ b/participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/service/ConfigService.java
@@ -98,8 +98,4 @@ public class ConfigService {
elementConfig = new ElementConfig();
LOGGER.info("Messages and service deactivated");
}
-
- public List<ElementMessage> getMessages() {
- return handler.getMessages();
- }
}
diff --git a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageHandlerTest.java b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageHandlerTest.java
index 84c6305e2..37d378b7a 100644
--- a/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageHandlerTest.java
+++ b/participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/handler/MessageHandlerTest.java
@@ -83,8 +83,6 @@ class MessageHandlerTest {
var message = new ElementStatus();
messageHandler.handleMessage(message);
verify(bridge).handleMessage(message);
- assertThat(messageHandler.getMessages()).hasSize(1);
- assertThat(messageHandler.getMessages().get(0)).isEqualTo(message);
messageHandler.deactivateElement();
}
@@ -104,8 +102,6 @@ class MessageHandlerTest {
var message = new ElementStatus();
messageHandler.handleMessage(message);
verify(sink).handleMessage(message);
- assertThat(messageHandler.getMessages()).hasSize(1);
- assertThat(messageHandler.getMessages().get(0)).isEqualTo(message);
messageHandler.deactivateElement();
}
diff --git a/participant/pom.xml b/participant/pom.xml
index 1e692eb60..7f5a89ae1 100644
--- a/participant/pom.xml
+++ b/participant/pom.xml
@@ -116,6 +116,11 @@
<artifactId>micrometer-registry-prometheus</artifactId>
<version>${version.io.micrometer}</version>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-aop</artifactId>
+ <version>${version.springboot}</version>
+ </dependency>
</dependencies>
<build>