Uplift prometheus depedencies 50/140250/1
authorwaynedunican <wayne.dunican@est.tech>
Wed, 12 Feb 2025 15:09:15 +0000 (15:09 +0000)
committerwaynedunican <wayne.dunican@est.tech>
Tue, 18 Feb 2025 15:20:30 +0000 (15:20 +0000)
Issue-ID: POLICY-5190
Change-Id: I04469a449733f01c9c046f41d5eedaa05312a912
Signed-off-by: waynedunican <wayne.dunican@est.tech>
policy-endpoints/pom.xml
policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java

index eb88455..97426c0 100644 (file)
@@ -2,7 +2,7 @@
   ============LICENSE_START=======================================================
    Copyright (C) 2022 Ericsson. All rights reserved.
    Modifications Copyright (C) 2018-2022 AT&T Intellectual Property. All rights reserved.
-   Modifications Copyright (C) 2019-2024 Nordix Foundation.
+   Modifications Copyright (C) 2019-2025 Nordix Foundation.
    Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
         </dependency>
         <dependency>
             <groupId>io.prometheus</groupId>
-            <artifactId>simpleclient_hotspot</artifactId>
+            <artifactId>prometheus-metrics-instrumentation-jvm</artifactId>
         </dependency>
         <dependency>
             <groupId>io.prometheus</groupId>
-            <artifactId>simpleclient_servlet_jakarta</artifactId>
+            <artifactId>prometheus-metrics-exporter-servlet-jakarta</artifactId>
         </dependency>
         <dependency>
             <groupId>jakarta.ws.rs</groupId>
index 78858a7..ed39211 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023-2025 Nordix Foundation.
  * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * 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.common.endpoints.http.server.internal;
 
-import io.prometheus.client.hotspot.DefaultExports;
-import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet;
+import io.prometheus.metrics.exporter.servlet.jakarta.PrometheusMetricsServlet;
+import io.prometheus.metrics.instrumentation.jvm.JvmMetrics;
 import jakarta.servlet.Servlet;
 import java.util.EnumSet;
 import java.util.HashMap;
@@ -506,14 +508,14 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
 
     @Override
     public void setPrometheus(String metricsPath) {
-        this.getServlet(MetricsServlet.class, metricsPath);
-        DefaultExports.initialize();
+        this.getServlet(PrometheusMetricsServlet.class, metricsPath);
+        JvmMetrics.builder().register();
     }
 
     @Override
     public boolean isPrometheus() {
         for (ServletHolder servlet : context.getServletHandler().getServlets()) {
-            if (MetricsServlet.class.getName().equals(servlet.getClassName())) {
+            if (PrometheusMetricsServlet.class.getName().equals(servlet.getClassName())) {
                 return true;
             }
         }
index 10d4005..e37cabc 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
- * Modifications Copyright 2023-2024 Nordix Foundation.
+ * Modifications Copyright 2023-2025 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,6 +17,8 @@
  * 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=========================================================
  */
 
@@ -28,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet;
+import io.prometheus.metrics.exporter.servlet.jakarta.PrometheusMetricsServlet;
 import jakarta.ws.rs.client.Entity;
 import jakarta.ws.rs.client.InvocationCallback;
 import jakarta.ws.rs.core.MediaType;
@@ -403,7 +405,8 @@ class HttpClientTest {
         httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + DOT_PAP
                         + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true");
         httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + DOT_PAP
-                        + PolicyEndPointProperties.PROPERTY_HTTP_SERVLET_CLASS_SUFFIX, MetricsServlet.class.getName());
+                        + PolicyEndPointProperties.PROPERTY_HTTP_SERVLET_CLASS_SUFFIX,
+            PrometheusMetricsServlet.class.getName());
         httpProperties.setProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + DOT_PAP
                                            + PolicyEndPointProperties.PROPERTY_HTTP_SERVLET_URIPATH_SUFFIX,
                                    "/pap/test/random/metrics");
index 399754a..46316d8 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020, 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023-2025 Nordix Foundation.
  * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +17,8 @@
  * 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=========================================================
  */
 
@@ -32,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.google.gson.Gson;
-import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet;
+import io.prometheus.metrics.exporter.servlet.jakarta.PrometheusMetricsServlet;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
@@ -59,7 +61,7 @@ import org.slf4j.LoggerFactory;
  * HttpServletServer JUNIT tests.
  */
 class HttpServerTest {
-    private static final String JVM_MEMORY_BYTES_USED = "jvm_memory_bytes_used";
+    private static final String JVM_MEMORY_BYTES_USED = "jvm_memory_used_bytes";
     private static final String METRICS_URI = "/metrics";
     private static final String PROMETHEUS = "prometheus";
     private static final String LOCALHOST = "localhost";
@@ -227,7 +229,7 @@ class HttpServerTest {
         HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory()
             .build(PROMETHEUS, LOCALHOST, port, "/", false, true);
 
-        server.addStdServletClass("/prom-generic-servlet/metrics", MetricsServlet.class.getName());
+        server.addStdServletClass("/prom-generic-servlet/metrics", PrometheusMetricsServlet.class.getName());
         server.waitedStart(5000);
 
         assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive());
index 431dae7..917bf82 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,6 +17,8 @@
  * 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=========================================================
  */
 
@@ -32,7 +34,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet;
+import io.prometheus.metrics.exporter.servlet.jakarta.PrometheusMetricsServlet;
 import jakarta.servlet.FilterChain;
 import jakarta.servlet.ServletRequest;
 import jakarta.servlet.ServletResponse;
@@ -230,7 +232,7 @@ class RestServerTest {
     @Test
     void testStandardServletAddedToProperty() {
         when(params.getServletUriPath()).thenReturn("/metrics");
-        when(params.getServletClass()).thenReturn(MetricsServlet.class.getName());
+        when(params.getServletClass()).thenReturn(PrometheusMetricsServlet.class.getName());
         rest = new RestServer(params, Filter2.class, Provider1.class, Provider2.class);
         ArgumentCaptor<Properties> cap = ArgumentCaptor.forClass(Properties.class);
         verify(serverFactory).build(cap.capture());
@@ -241,7 +243,7 @@ class RestServerTest {
         assertEquals("false", props.getProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_PROMETHEUS_SUFFIX));
         assertEquals(METRICS_URI,
             props.getProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SERVLET_URIPATH_SUFFIX));
-        assertEquals(MetricsServlet.class.getName(),
+        assertEquals(PrometheusMetricsServlet.class.getName(),
             props.getProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SERVLET_CLASS_SUFFIX));
     }