aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/main
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2022-06-09 10:03:13 +0100
committeradheli.tavares <adheli.tavares@est.tech>2022-06-09 10:05:15 +0100
commitfe43edecef38cc06f7c540eaf43016e38f360227 (patch)
tree5b7535d3440c661385b3d2d02dff3652ab69b5e9 /runtime-acm/src/main
parente7deff07e3b30ef564ced876bdfe0b68911965a8 (diff)
Fix configuration for Prometheus metrics
JVM related metrics were not being exposed due to spring boot bug when loading beans configuration. Issue-ID: POLICY-4146 Change-Id: I334c60b0c0d087c63b28bf44704aa3e909eca646 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'runtime-acm/src/main')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java5
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java40
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java5
-rw-r--r--runtime-acm/src/main/resources/application.yaml3
4 files changed, 46 insertions, 7 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java
index f51497266..6776e59a6 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/ConverterConfiguration.java
@@ -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,7 +20,6 @@
package org.onap.policy.clamp.acm.runtime.config;
-import java.util.Arrays;
import java.util.List;
import org.onap.policy.clamp.common.acm.rest.CoderHttpMesageConverter;
import org.springframework.context.annotation.Configuration;
@@ -38,7 +37,7 @@ public class ConverterConfiguration implements WebMvcConfigurer {
converters.add(new CoderHttpMesageConverter<>("json"));
StringHttpMessageConverter converter = new StringHttpMessageConverter();
- converter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN));
+ converter.setSupportedMediaTypes(List.of(MediaType.TEXT_PLAIN));
converters.add(converter);
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java
new file mode 100644
index 000000000..dca31cdb8
--- /dev/null
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/config/MetricsConfiguration.java
@@ -0,0 +1,40 @@
+/*-
+ * ============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.runtime.config;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class MetricsConfiguration {
+
+ /**
+ * Load up the metrics registry.
+ */
+ @Bean
+ InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
+ MeterRegistry registry) {
+ return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
+ }
+}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java
index 7907de7be..107de58c9 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/AbstractRestController.java
@@ -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.
@@ -34,7 +34,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
* Common superclass to provide REST endpoints for the participant simulator.
*/
// @formatter:off
-@RequestMapping(value = "/v2", produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML})
+@RequestMapping(value = "/onap/policy/clamp/acm/v2",
+ produces = {MediaType.APPLICATION_JSON, AbstractRestController.APPLICATION_YAML})
@Api(value = "Automation Composition Commissioning API")
@SwaggerDefinition(
info = @Info(description =
diff --git a/runtime-acm/src/main/resources/application.yaml b/runtime-acm/src/main/resources/application.yaml
index 0a5bb8b5d..21c754c1a 100644
--- a/runtime-acm/src/main/resources/application.yaml
+++ b/runtime-acm/src/main/resources/application.yaml
@@ -32,8 +32,6 @@ security:
server:
port: 6969
- servlet:
- context-path: /onap/policy/clamp/acm
error:
path: /error
@@ -62,5 +60,6 @@ runtime:
management:
endpoints:
web:
+ base-path: /
exposure:
include: health, metrics, prometheus