Adding Prometheus counts to XacmlPdpStatisticsManager
Issue-ID: POLICY-3762
Signed-off-by: isaac <isaac.adorno@att.com>
Change-Id: I865fc01dac91fe77421fc2fceb72eac49c9d8a78
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 c040ae6..609da8f 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 @@
@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 @@
*/
@Synchronized
public long updateDeploySuccessCount() {
+ deploymentsCounter.labels(PrometheusUtils.DEPLOY_OPERATION,
+ PdpResponseStatus.SUCCESS.name()).inc();
return ++deploySuccessCount;
}
@@ -118,6 +131,8 @@
*/
@Synchronized
public long updateDeployFailureCount() {
+ deploymentsCounter.labels(PrometheusUtils.DEPLOY_OPERATION,
+ PdpResponseStatus.FAIL.name()).inc();
return ++deployFailureCount;
}
@@ -128,6 +143,8 @@
*/
@Synchronized
public long updateUndeploySuccessCount() {
+ deploymentsCounter.labels(PrometheusUtils.UNDEPLOY_OPERATION,
+ PdpResponseStatus.SUCCESS.name()).inc();
return ++undeploySuccessCount;
}
@@ -138,6 +155,8 @@
*/
@Synchronized
public long updateUndeployFailureCount() {
+ deploymentsCounter.labels(PrometheusUtils.UNDEPLOY_OPERATION,
+ PdpResponseStatus.FAIL.name()).inc();
return ++undeployFailureCount;
}