============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>
* 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;
@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;
}
}
* ================================================================================
* 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.
* 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=========================================================
*/
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;
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");
* 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");
* 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=========================================================
*/
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;
* 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";
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());
* ================================================================================
* 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.
* 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=========================================================
*/
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;
@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());
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));
}