diff options
author | 2025-02-12 15:09:15 +0000 | |
---|---|---|
committer | 2025-02-18 15:20:30 +0000 | |
commit | 6324d28cf7147c0f3366f7e0f1e5a0053da5e513 (patch) | |
tree | 7ed52ed7f321adadc266c7be11cd45fe0bee7c44 /policy-endpoints | |
parent | a02b24c3808c0ad49d66b25d59bf2f76463a1c8e (diff) |
Uplift prometheus depedencies
Issue-ID: POLICY-5190
Change-Id: I04469a449733f01c9c046f41d5eedaa05312a912
Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'policy-endpoints')
5 files changed, 29 insertions, 20 deletions
diff --git a/policy-endpoints/pom.xml b/policy-endpoints/pom.xml index eb88455d..97426c06 100644 --- a/policy-endpoints/pom.xml +++ b/policy-endpoints/pom.xml @@ -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"); @@ -95,11 +95,11 @@ </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> diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java index 78858a77..ed392119 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java @@ -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"); @@ -17,13 +17,15 @@ * 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; } } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java index 10d40051..e37cabc1 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java @@ -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"); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java index 399754a6..46316d89 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java @@ -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()); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java index 431dae7c..917bf82c 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java @@ -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)); } |