summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/main
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2021-03-03 12:05:02 -0600
committerjhh <jorge.hernandez-herrero@att.com>2021-03-03 19:45:10 -0600
commit8eb77a1d2ade5eff3c2e736d7a7517d14e2a2d92 (patch)
treed7fa1613ca044f813ff55b2b31e69420dd249bae /feature-lifecycle/src/main
parent1e026920a11f1194f8cb7d353a9681694319c697 (diff)
enable viewing lifecycle statistics with telemetry
Issue-ID: POLICY-3121 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I25e8c4439c0a6beabe532c17cc58919f369f17f0 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/main')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java5
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java12
2 files changed, 16 insertions, 1 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index 4f1a4f31..ea5e49f4 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -595,7 +595,10 @@ public class LifecycleFsm implements Startable {
return status;
}
- private PdpStatistics statisticsPayload() {
+ /**
+ * It provides a snapshot of the current statistics.
+ */
+ public PdpStatistics statisticsPayload() {
PdpStatistics updateStats = new PdpStatistics(stats);
updateStats.setTimeStamp(Instant.now());
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java
index e9969094..9af78ae6 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/server/restful/RestLifecycleManager.java
@@ -45,6 +45,7 @@ import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.drools.lifecycle.LifecycleFeature;
import org.onap.policy.drools.lifecycle.PolicyTypeController;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -408,6 +409,17 @@ public class RestLifecycleManager {
return Response.status(Response.Status.OK).entity(Collections.emptyList()).build();
}
+ /**
+ * Get current counts.
+ */
+
+ @GET
+ @Path("statistics")
+ @ApiOperation(value = "Gets Policy Statistics", response = PdpStatistics.class)
+ public Response stats() {
+ return Response.status(Response.Status.OK).entity(LifecycleFeature.getFsm().statisticsPayload()).build();
+ }
+
private Response deployUndeployOperation(String policy, boolean deploy) {
ToscaPolicy toscaPolicy = getToscaPolicy(policy);
if (toscaPolicy == null) {