From 4873a65384639607dbab45846a7ff53775ee0a79 Mon Sep 17 00:00:00 2001 From: isaac Date: Mon, 28 Feb 2022 14:49:07 -0600 Subject: Adding Prometheus counts to XacmlPdpStatisticsManager Issue-ID: POLICY-3762 Signed-off-by: isaac Change-Id: I865fc01dac91fe77421fc2fceb72eac49c9d8a78 --- .../pdpx/main/rest/XacmlPdpStatisticsManager.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpStatisticsManager.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpStatisticsManager.java index c040ae6a..609da8f6 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpStatisticsManager.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpStatisticsManager.java @@ -20,9 +20,12 @@ package org.onap.policy.pdpx.main.rest; +import io.prometheus.client.Counter; import lombok.Getter; import lombok.Setter; import lombok.Synchronized; +import org.onap.policy.common.utils.resources.PrometheusUtils; +import org.onap.policy.models.pdp.enums.PdpResponseStatus; /** * Class to hold statistical data for xacmlPdp component. @@ -32,6 +35,14 @@ public class XacmlPdpStatisticsManager { @Getter @Setter private static XacmlPdpStatisticsManager current = null; + protected static final String PROMETHEUS_NAMESPACE = "pdpx"; + + protected static final Counter deploymentsCounter = + Counter.build().namespace(PROMETHEUS_NAMESPACE).name(PrometheusUtils.POLICY_DEPLOYMENTS_METRIC) + .labelNames(PrometheusUtils.OPERATION_METRIC_LABEL, + PrometheusUtils.STATUS_METRIC_LABEL) + .help(PrometheusUtils.POLICY_DEPLOYMENT_HELP) + .register(); private long totalPolicyTypesCount; private long totalPoliciesCount; @@ -108,6 +119,8 @@ public class XacmlPdpStatisticsManager { */ @Synchronized public long updateDeploySuccessCount() { + deploymentsCounter.labels(PrometheusUtils.DEPLOY_OPERATION, + PdpResponseStatus.SUCCESS.name()).inc(); return ++deploySuccessCount; } @@ -118,6 +131,8 @@ public class XacmlPdpStatisticsManager { */ @Synchronized public long updateDeployFailureCount() { + deploymentsCounter.labels(PrometheusUtils.DEPLOY_OPERATION, + PdpResponseStatus.FAIL.name()).inc(); return ++deployFailureCount; } @@ -128,6 +143,8 @@ public class XacmlPdpStatisticsManager { */ @Synchronized public long updateUndeploySuccessCount() { + deploymentsCounter.labels(PrometheusUtils.UNDEPLOY_OPERATION, + PdpResponseStatus.SUCCESS.name()).inc(); return ++undeploySuccessCount; } @@ -138,6 +155,8 @@ public class XacmlPdpStatisticsManager { */ @Synchronized public long updateUndeployFailureCount() { + deploymentsCounter.labels(PrometheusUtils.UNDEPLOY_OPERATION, + PdpResponseStatus.FAIL.name()).inc(); return ++undeployFailureCount; } -- cgit 1.2.3-korg