aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/main/java/org/onap')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/PapConstants.java1
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/notification/DeploymentStatus.java26
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java9
3 files changed, 35 insertions, 1 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/PapConstants.java b/main/src/main/java/org/onap/policy/pap/main/PapConstants.java
index df43c69f..36d5eeb2 100644
--- a/main/src/main/java/org/onap/policy/pap/main/PapConstants.java
+++ b/main/src/main/java/org/onap/policy/pap/main/PapConstants.java
@@ -33,6 +33,7 @@ public final class PapConstants {
public static final String REG_STATISTICS_MANAGER = "object:manager/statistics";
public static final String REG_PDP_MODIFY_LOCK = "lock:pdp";
public static final String REG_PDP_MODIFY_MAP = "object:pdp/modify/map";
+ public static final String REG_METER_REGISTRY = "object:meter/registry";
// topic names
public static final String TOPIC_POLICY_PDP_PAP = "POLICY-PDP-PAP";
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.
*/
diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
index 00207220..f8c4fb32 100644
--- a/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
+++ b/main/src/main/java/org/onap/policy/pap/main/startstop/PapActivator.java
@@ -22,6 +22,7 @@
package org.onap.policy.pap.main.startstop;
+import io.micrometer.core.instrument.MeterRegistry;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -92,7 +93,8 @@ public class PapActivator extends ServiceManagerContainer {
* @param papParameterGroup the parameters for the pap service
*/
public PapActivator(PapParameterGroup papParameterGroup, PolicyNotifier policyNotifier,
- PdpHeartbeatListener pdpHeartbeatListener, PdpModifyRequestMap pdpModifyRequestMap) {
+ PdpHeartbeatListener pdpHeartbeatListener, PdpModifyRequestMap pdpModifyRequestMap,
+ MeterRegistry meterRegistry) {
super("Policy PAP");
this.papParameterGroup = papParameterGroup;
TopicEndpointManager.getManager().addTopics(papParameterGroup.getTopicParameterGroup());
@@ -118,6 +120,11 @@ public class PapActivator extends ServiceManagerContainer {
final AtomicReference<PdpModifyRequestMap> requestMap = new AtomicReference<>();
// @formatter:off
+
+ addAction("Meter Registry",
+ () -> Registry.register(PapConstants.REG_METER_REGISTRY, meterRegistry),
+ () -> Registry.unregister(PapConstants.REG_METER_REGISTRY));
+
addAction("PAP parameters",
() -> ParameterService.register(papParameterGroup),
() -> ParameterService.deregister(papParameterGroup.getName()));