Uplift prometheus dependencies 93/140293/1
authorwaynedunican <wayne.dunican@est.tech>
Wed, 12 Feb 2025 15:12:33 +0000 (15:12 +0000)
committerwaynedunican <wayne.dunican@est.tech>
Fri, 21 Feb 2025 15:53:33 +0000 (15:53 +0000)
Issue-ID: POLICY-5190
Change-Id: Id89b79aaaac2559072511dd1050df67724803403
Signed-off-by: waynedunican <wayne.dunican@est.tech>
main/pom.xml
main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpStatisticsManager.java

index f2ac9f4..5438707 100644 (file)
@@ -4,7 +4,7 @@
   ================================================================================
   Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
   Modifications Copyright (C) 2020 Bell Canada.
-  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=========================================================
   -->
 
         </dependency>
         <dependency>
             <groupId>io.prometheus</groupId>
-            <artifactId>simpleclient</artifactId>
+            <artifactId>prometheus-metrics-core</artifactId>
         </dependency>
         <dependency>
             <groupId>jakarta.validation</groupId>
         </dependency>
         <dependency>
             <groupId>io.prometheus</groupId>
-            <artifactId>simpleclient_logback</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>io.prometheus</groupId>
-            <artifactId>simpleclient_hotspot</artifactId>
+            <artifactId>prometheus-metrics-instrumentation-jvm</artifactId>
             <scope>runtime</scope>
         </dependency>
         <dependency>
             <groupId>io.prometheus</groupId>
-            <artifactId>simpleclient_servlet_jakarta</artifactId>
+            <artifactId>prometheus-metrics-exporter-servlet-jakarta</artifactId>
             <scope>runtime</scope>
         </dependency>
         <dependency>
index ab0ebd6..2fb7e1d 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2019, 2021-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 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.
@@ -21,7 +21,7 @@
 
 package org.onap.policy.pdpx.main.rest;
 
-import io.prometheus.client.Counter;
+import io.prometheus.metrics.core.metrics.Counter;
 import java.util.HashMap;
 import java.util.Map;
 import lombok.Getter;
@@ -48,14 +48,16 @@ public class XacmlPdpStatisticsManager {
     public static final String APPLICATION = "application";
 
     protected static final Counter deploymentsCounter =
-        Counter.build().namespace(PROMETHEUS_NAMESPACE).name(PrometheusUtils.POLICY_DEPLOYMENTS_METRIC)
+        Counter.builder()
+            .name(PROMETHEUS_NAMESPACE + "_" + PrometheusUtils.POLICY_DEPLOYMENTS_METRIC)
             .labelNames(PrometheusUtils.OPERATION_METRIC_LABEL,
                 PrometheusUtils.STATUS_METRIC_LABEL)
             .help(PrometheusUtils.POLICY_DEPLOYMENT_HELP)
             .register();
 
     protected static final Counter decisionsCounter =
-        Counter.build().namespace(PROMETHEUS_NAMESPACE).name(POLICY_DECISIONS_METRIC)
+        Counter.builder()
+            .name(PROMETHEUS_NAMESPACE + "_" + POLICY_DECISIONS_METRIC)
             .labelNames(APPLICATION, PrometheusUtils.STATUS_METRIC_LABEL)
             .help(POLICY_DECISIONS_HELP)
             .register();
@@ -134,7 +136,7 @@ public class XacmlPdpStatisticsManager {
      */
     @Synchronized
     public void updatePermitDecisionsCount(String appName) {
-        decisionsCounter.labels(appName, PERMIT_OPERATION).inc();
+        decisionsCounter.labelValues(appName, PERMIT_OPERATION).inc();
         updateApplicationMetrics(appName, "permit_decisions_count");
         ++permitDecisionsCount;
     }
@@ -144,7 +146,7 @@ public class XacmlPdpStatisticsManager {
      */
     @Synchronized
     public void updateDenyDecisionsCount(String appName) {
-        decisionsCounter.labels(appName, DENY_OPERATION).inc();
+        decisionsCounter.labelValues(appName, DENY_OPERATION).inc();
         updateApplicationMetrics(appName, "deny_decisions_count");
         ++denyDecisionsCount;
     }
@@ -154,7 +156,7 @@ public class XacmlPdpStatisticsManager {
      */
     @Synchronized
     public void updateIndeterminantDecisionsCount(String appName) {
-        decisionsCounter.labels(appName, INDETERMINANT_OPERATION).inc();
+        decisionsCounter.labelValues(appName, INDETERMINANT_OPERATION).inc();
         updateApplicationMetrics(appName, "indeterminant_decisions_count");
         ++indeterminantDecisionsCount;
     }
@@ -164,7 +166,7 @@ public class XacmlPdpStatisticsManager {
      */
     @Synchronized
     public void updateNotApplicableDecisionsCount(String appName) {
-        decisionsCounter.labels(appName, NOT_APPLICABLE_OPERATION).inc();
+        decisionsCounter.labelValues(appName, NOT_APPLICABLE_OPERATION).inc();
         updateApplicationMetrics(appName, "not_applicable_decisions_count");
         ++notApplicableDecisionsCount;
     }
@@ -174,7 +176,7 @@ public class XacmlPdpStatisticsManager {
      */
     @Synchronized
     public void updateDeploySuccessCount() {
-        deploymentsCounter.labels(PrometheusUtils.DEPLOY_OPERATION,
+        deploymentsCounter.labelValues(PrometheusUtils.DEPLOY_OPERATION,
             PdpResponseStatus.SUCCESS.name()).inc();
         ++deploySuccessCount;
     }
@@ -184,7 +186,7 @@ public class XacmlPdpStatisticsManager {
      */
     @Synchronized
     public void updateDeployFailureCount() {
-        deploymentsCounter.labels(PrometheusUtils.DEPLOY_OPERATION,
+        deploymentsCounter.labelValues(PrometheusUtils.DEPLOY_OPERATION,
             PdpResponseStatus.FAIL.name()).inc();
         ++deployFailureCount;
     }
@@ -194,7 +196,7 @@ public class XacmlPdpStatisticsManager {
      */
     @Synchronized
     public void updateUndeploySuccessCount() {
-        deploymentsCounter.labels(PrometheusUtils.UNDEPLOY_OPERATION,
+        deploymentsCounter.labelValues(PrometheusUtils.UNDEPLOY_OPERATION,
             PdpResponseStatus.SUCCESS.name()).inc();
         ++undeploySuccessCount;
     }
@@ -204,7 +206,7 @@ public class XacmlPdpStatisticsManager {
      */
     @Synchronized
     public void updateUndeployFailureCount() {
-        deploymentsCounter.labels(PrometheusUtils.UNDEPLOY_OPERATION,
+        deploymentsCounter.labelValues(PrometheusUtils.UNDEPLOY_OPERATION,
             PdpResponseStatus.FAIL.name()).inc();
         ++undeployFailureCount;
     }