aboutsummaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2022-02-10 13:18:43 +0000
committerGerrit Code Review <gerrit@onap.org>2022-02-10 13:18:43 +0000
commit2f2c5465cd23c8c3300a5c3d185806bb3e7d73c1 (patch)
tree8dc32111bc837459be7e61b048e3fd073e3bc5a8 /model
parentc9da04cc4ff4b133edd68ceee77f5bb5128d6574 (diff)
parentd71f322fa9eb51967527b14c1eeeba49838464be (diff)
Merge "rename metrics as per global constants for prometheus"
Diffstat (limited to 'model')
-rw-r--r--model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java36
-rw-r--r--model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java28
2 files changed, 31 insertions, 33 deletions
diff --git a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java
index 36df645a5..1420d1e0d 100644
--- a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java
+++ b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java
@@ -34,6 +34,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
+import org.onap.policy.common.utils.resources.PrometheusUtils;
import org.onap.policy.common.utils.validation.Assertions;
/**
@@ -46,21 +47,22 @@ public class AxEngineStats extends AxConcept {
private static final long serialVersionUID = -6981129081962785368L;
private static final int HASH_CODE_PRIME = 32;
static final String ENGINE_INSTANCE_ID = "engine_instance_id";
- static final Gauge ENGINE_EVENTS_EXECUTED_COUNT = Gauge.build().name("apex_engine_events_executed_count")
- .labelNames(ENGINE_INSTANCE_ID)
- .help("Total number of APEX events processed by the engine.").register();
- static final Gauge ENGINE_UPTIME = Gauge.build().name("apex_engine_uptime")
- .labelNames(ENGINE_INSTANCE_ID)
- .help("Time elapsed since the engine was started.").register();
- static final Gauge ENGINE_START_TIMESTAMP = Gauge.build().name("apex_engine_last_start_timestamp_epoch")
- .labelNames(ENGINE_INSTANCE_ID)
- .help("Epoch timestamp of the instance when engine was last started.").register();
- static final Gauge ENGINE_AVG_EXECUTION_TIME = Gauge.build().name("apex_engine_average_execution_time_seconds")
- .labelNames(ENGINE_INSTANCE_ID)
- .help("Average time taken to execute an APEX policy in seconds.").register();
+ static final Gauge ENGINE_EVENT_EXECUTIONS = Gauge.build().name("engine_event_executions")
+ .namespace(PrometheusUtils.PdpType.PDPA.getNamespace()).labelNames(ENGINE_INSTANCE_ID)
+ .help("Total number of APEX events processed by the engine.").register();
+ static final Gauge ENGINE_UPTIME = Gauge.build().name("engine_uptime")
+ .namespace(PrometheusUtils.PdpType.PDPA.getNamespace()).labelNames(ENGINE_INSTANCE_ID)
+ .help("Time elapsed since the engine was started.").register();
+ static final Gauge ENGINE_START_TIMESTAMP = Gauge.build().name("engine_last_start_timestamp_epoch")
+ .namespace(PrometheusUtils.PdpType.PDPA.getNamespace()).labelNames(ENGINE_INSTANCE_ID)
+ .help("Epoch timestamp of the instance when engine was last started.").register();
+ static final Gauge ENGINE_AVG_EXECUTION_TIME = Gauge.build().name("engine_average_execution_time_seconds")
+ .namespace(PrometheusUtils.PdpType.PDPA.getNamespace()).labelNames(ENGINE_INSTANCE_ID)
+ .help("Average time taken to execute an APEX policy in seconds.").register();
static final Histogram ENGINE_LAST_EXECUTION_TIME = Histogram.build()
- .name("apex_engine_last_execution_time").labelNames(ENGINE_INSTANCE_ID)
- .help("Time taken to execute the last APEX policy in seconds.").register();
+ .namespace(PrometheusUtils.PdpType.PDPA.getNamespace())
+ .name("engine_last_execution_time").labelNames(ENGINE_INSTANCE_ID)
+ .help("Time taken to execute the last APEX policy in seconds.").register();
private AxReferenceKey key;
private long timeStamp;
@@ -97,7 +99,7 @@ public class AxEngineStats extends AxConcept {
return;
}
ENGINE_UPTIME.labels(engineId).set(upTime / 1000d);
- ENGINE_EVENTS_EXECUTED_COUNT.labels(engineId).set(this.eventCount);
+ ENGINE_EVENT_EXECUTIONS.labels(engineId).set(this.eventCount);
ENGINE_START_TIMESTAMP.labels(engineId).set(this.lastStart);
ENGINE_AVG_EXECUTION_TIME.labels(engineId).set(this.averageExecutionTime / 1000d);
ENGINE_LAST_EXECUTION_TIME.labels(engineId).observe(this.lastExecutionTime / 1000d);
@@ -216,7 +218,7 @@ public class AxEngineStats extends AxConcept {
*/
public void setEventCount(final long eventCount) {
this.eventCount = eventCount;
- ENGINE_EVENTS_EXECUTED_COUNT.labels(getKey().getParentArtifactKey().getId())
+ ENGINE_EVENT_EXECUTIONS.labels(getKey().getParentArtifactKey().getId())
.set(this.eventCount);
}
@@ -328,7 +330,7 @@ public class AxEngineStats extends AxConcept {
}
lastEnterTime = now;
timeStamp = now;
- ENGINE_EVENTS_EXECUTED_COUNT.labels(getKey().getParentArtifactKey().getId()).set(this.eventCount);
+ ENGINE_EVENT_EXECUTIONS.labels(getKey().getParentArtifactKey().getId()).set(this.eventCount);
}
/**
diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
index a40e8cbbf..3eca27c08 100644
--- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
+++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
@@ -224,40 +224,36 @@ public class EngineStatsTest {
}
private void checkUpTimeMetric(AxEngineStats stats) {
- Double upTimeMetric = CollectorRegistry.defaultRegistry.getSampleValue("apex_engine_uptime",
- new String[]{AxEngineStats.ENGINE_INSTANCE_ID},
- new String[]{ENGINE_KEY + ":" + ENGINE_VERSION}) * 1000d;
+ Double upTimeMetric = CollectorRegistry.defaultRegistry.getSampleValue("pdpa_engine_uptime",
+ new String[]{AxEngineStats.ENGINE_INSTANCE_ID}, new String[]{ENGINE_KEY + ":" + ENGINE_VERSION}) * 1000d;
assertEquals(upTimeMetric.longValue(), stats.getUpTime());
}
private void checkEventsCountMetric(AxEngineStats stats) {
- Double eventsCountMetric = CollectorRegistry.defaultRegistry
- .getSampleValue("apex_engine_events_executed_count",
- new String[]{AxEngineStats.ENGINE_INSTANCE_ID},
- new String[]{ENGINE_KEY + ":" + ENGINE_VERSION});
+ Double eventsCountMetric = CollectorRegistry.defaultRegistry.getSampleValue("pdpa_engine_event_executions",
+ new String[]{AxEngineStats.ENGINE_INSTANCE_ID}, new String[]{ENGINE_KEY + ":" + ENGINE_VERSION});
assertEquals(eventsCountMetric.longValue(), stats.getEventCount());
}
private void checkLastExecTimeMetric(AxEngineStats stats) {
Double lastExecTimeMetric = CollectorRegistry.defaultRegistry
- .getSampleValue("apex_engine_last_execution_time_sum", new String[]{AxEngineStats.ENGINE_INSTANCE_ID},
- new String[]{ENGINE_KEY + ":" + ENGINE_VERSION}) * 1000d;
+ .getSampleValue("pdpa_engine_last_execution_time_sum", new String[]{AxEngineStats.ENGINE_INSTANCE_ID},
+ new String[]{ENGINE_KEY + ":" + ENGINE_VERSION}) * 1000d;
assertEquals(lastExecTimeMetric.longValue(), stats.getLastExecutionTime());
}
private void checkEngineStartTimestampMetric(AxEngineStats stats) {
Double engineStartTimestampMetric = CollectorRegistry.defaultRegistry
- .getSampleValue("apex_engine_last_start_timestamp_epoch",
- new String[]{AxEngineStats.ENGINE_INSTANCE_ID},
- new String[]{ENGINE_KEY + ":" + ENGINE_VERSION});
+ .getSampleValue("pdpa_engine_last_start_timestamp_epoch",
+ new String[]{AxEngineStats.ENGINE_INSTANCE_ID}, new String[]{ENGINE_KEY + ":" + ENGINE_VERSION});
assertEquals(engineStartTimestampMetric.longValue(), stats.getLastStart());
}
private void checkAvgExecTimeMetric(AxEngineStats stats) {
Double avgExecTimeMetric = CollectorRegistry.defaultRegistry
- .getSampleValue("apex_engine_average_execution_time_seconds",
- new String[]{AxEngineStats.ENGINE_INSTANCE_ID},
- new String[]{ENGINE_KEY + ":" + ENGINE_VERSION}) * 1000d;
+ .getSampleValue("pdpa_engine_average_execution_time_seconds",
+ new String[]{AxEngineStats.ENGINE_INSTANCE_ID},
+ new String[]{ENGINE_KEY + ":" + ENGINE_VERSION}) * 1000d;
assertEquals(avgExecTimeMetric, Double.valueOf(stats.getAverageExecutionTime()));
}
@@ -268,4 +264,4 @@ public class EngineStatsTest {
checkEngineStartTimestampMetric(stats);
checkEngineStartTimestampMetric(stats);
}
-}
+} \ No newline at end of file