diff options
author | a.sreekumar <ajith.sreekumar@bell.ca> | 2022-02-21 13:13:20 +0000 |
---|---|---|
committer | a.sreekumar <ajith.sreekumar@bell.ca> | 2022-02-23 10:29:36 +0000 |
commit | f0262c356f164c9a84bd3199e5f32b16356726fa (patch) | |
tree | fedc98bd66f3ba3223e646f145206bf9c961bad5 /main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java | |
parent | beef773a297cbeb5c5abfb5e75e678e39d3d1523 (diff) |
Adding deployment metrics to PAP
Change-Id: I4b6a93045c1ddfd7fff037e7568b029e2e45b0b3
Issue-ID: POLICY-3757
Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java')
-rw-r--r-- | main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java b/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java index 20e59339..7a1aa107 100644 --- a/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java +++ b/main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java @@ -21,6 +21,7 @@ package org.onap.policy.pap.main.notification; +import io.micrometer.core.instrument.MeterRegistry; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -33,10 +34,13 @@ import java.util.function.BiPredicate; import java.util.stream.Collectors; import lombok.AccessLevel; import lombok.Getter; +import org.onap.policy.common.utils.resources.PrometheusUtils; +import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.pap.concepts.PolicyNotification; import org.onap.policy.models.pdp.concepts.PdpPolicyStatus; import org.onap.policy.models.pdp.concepts.PdpPolicyStatus.State; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.pap.main.PapConstants; import org.onap.policy.pap.main.notification.StatusAction.Action; import org.onap.policy.pap.main.service.PolicyStatusService; @@ -51,6 +55,7 @@ import org.onap.policy.pap.main.service.PolicyStatusService; * </ol> */ public class DeploymentStatus { + /** * Tracks the groups that have been loaded. */ @@ -123,6 +128,7 @@ public class DeploymentStatus { public void flush(PolicyNotification notif) { // must add notifications BEFORE deleting undeployments addNotifications(notif); + updateMetrics(); deleteUndeployments(); flush(); } @@ -171,6 +177,26 @@ public class DeploymentStatus { } } + private void updateMetrics() { + MeterRegistry meterRegistry = Registry.get(PapConstants.REG_METER_REGISTRY, MeterRegistry.class); + String counterName = "pap_" + PrometheusUtils.POLICY_DEPLOYMENTS_METRIC; + recordMap.forEach((key, value) -> { + if (value.getAction().equals(StatusAction.Action.UPDATED)) { + if (value.getStatus().getState().equals(State.SUCCESS)) { + meterRegistry.counter(counterName, PrometheusUtils.OPERATION_METRIC_LABEL, + value.getStatus().isDeploy() ? PrometheusUtils.DEPLOY_OPERATION + : PrometheusUtils.UNDEPLOY_OPERATION, + PrometheusUtils.STATUS_METRIC_LABEL, State.SUCCESS.name()).increment(); + } else if (value.getStatus().getState().equals(State.FAILURE)) { + meterRegistry.counter(counterName, PrometheusUtils.OPERATION_METRIC_LABEL, + value.getStatus().isDeploy() ? PrometheusUtils.DEPLOY_OPERATION + : PrometheusUtils.UNDEPLOY_OPERATION, + PrometheusUtils.STATUS_METRIC_LABEL, State.FAILURE.name()).increment(); + } + } + }); + } + /** * Deletes records for any policies that have been completely undeployed. */ |