Support prometheus metrics 73/141873/1 1.14.1
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Tue, 19 Aug 2025 13:36:52 +0000 (15:36 +0200)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Tue, 19 Aug 2025 13:36:52 +0000 (15:36 +0200)
Issue-ID: SDC-4760
Change-Id: I2954601229e5ce02dd8a95b66439e3bc55f0016d
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
sdc-workflow-designer-be/pom.xml
sdc-workflow-designer-be/src/main/resources/application.properties
sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/MetricsTest.java [new file with mode: 0644]

index d6c8c0e..e89a517 100644 (file)
             <artifactId>spring-boot-starter-actuator</artifactId>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>io.micrometer</groupId>
+            <artifactId>micrometer-registry-prometheus</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-text</artifactId>
index 1afdc73..2011e7f 100644 (file)
@@ -48,6 +48,7 @@ zusammen.cassandra.trustStorePassword=${CS_TRUST_STORE_PASSWORD:}
 
 #Actuators
 management.endpoint.health.show-details=always
+management.endpoints.web.exposure.include=*
 
 spring.output.ansi.enabled=always
 
diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/MetricsTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/MetricsTest.java
new file mode 100644 (file)
index 0000000..128df2b
--- /dev/null
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2025 Deutsche Telekom. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.sdc.workflow;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static org.hamcrest.Matchers.containsString;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+
+@SpringBootTest
+@AutoConfigureMockMvc
+@RunWith(SpringRunner.class)
+public class MetricsTest {
+
+    @Autowired
+    private MockMvc mockMvc;
+
+    @Test
+    public void prometheusEndpointShouldReturnMetrics() throws Exception {
+        mockMvc.perform(get("/actuator/prometheus"))
+               .andExpect(status().isOk())
+               .andExpect(content().string(containsString("# HELP")));
+    }
+}