From f09166cb5a3d1df958bf2686617c153e4e228b8f Mon Sep 17 00:00:00 2001 From: Nikola Koevski Date: Wed, 29 Apr 2020 15:49:35 +0200 Subject: [PATCH] feat(engine): add new pricing model metrics (#791) - executed decision instances (dmn tables and literal expressions) - root process instances (i.e. instances not started by call activity) - refactors involved tests from JUnit 3 to 4 related to CAM-11186 --- .../delegate/DmnDecisionEvaluationEvent.java | 5 + .../impl/DefaultDmnDecisionContext.java | 1 + .../DmnDecisionEvaluationEventImpl.java | 14 ++ .../metrics/DefaultEngineMetricCollector.java | 15 ++ .../DmnEngineMetricCollectorWrapper.java | 10 + .../engine/spi/DmnEngineMetricCollector.java | 12 ++ .../cfg/ProcessEngineConfigurationImpl.java | 3 + .../MetricsDecisionEvaluationListener.java | 9 +- .../parser/MetricsBpmnParseListener.java | 20 +- .../parser/MetricsExecutionListener.java | 17 +- .../bpm/engine/management/Metrics.java | 6 + .../api/mgmt/metrics/AbstractMetricsTest.java | 45 ++++- .../ActivityInstanceCountMetricsTest.java | 8 +- .../api/mgmt/metrics/DecisionMetricsTest.java | 175 ++++++++++++++++++ .../ExecutedDecisionElementsMetricsTest.java | 80 -------- .../mgmt/metrics/JobExecutorMetricsTest.java | 37 ++-- .../api/mgmt/metrics/MetricsDisabledTest.java | 42 ++++- .../test/api/mgmt/metrics/MetricsTest.java | 49 ++--- .../RootProcessInstanceMetricsTest.java | 145 +++++++++++++++ .../db/entitymanager/PurgeDatabaseTest.java | 2 +- 20 files changed, 560 insertions(+), 135 deletions(-) create mode 100644 engine/src/test/java/org/camunda/bpm/engine/test/api/mgmt/metrics/DecisionMetricsTest.java delete mode 100644 engine/src/test/java/org/camunda/bpm/engine/test/api/mgmt/metrics/ExecutedDecisionElementsMetricsTest.java create mode 100644 engine/src/test/java/org/camunda/bpm/engine/test/api/mgmt/metrics/RootProcessInstanceMetricsTest.java diff --git a/engine-dmn/engine/src/main/java/org/camunda/bpm/dmn/engine/delegate/DmnDecisionEvaluationEvent.java b/engine-dmn/engine/src/main/java/org/camunda/bpm/dmn/engine/delegate/DmnDecisionEvaluationEvent.java index b7aa7e5a566..d61dcdf021d 100644 --- a/engine-dmn/engine/src/main/java/org/camunda/bpm/dmn/engine/delegate/DmnDecisionEvaluationEvent.java +++ b/engine-dmn/engine/src/main/java/org/camunda/bpm/dmn/engine/delegate/DmnDecisionEvaluationEvent.java @@ -33,6 +33,11 @@ public interface DmnDecisionEvaluationEvent { */ Collection getRequiredDecisionResults(); + /** + * @return the number of executed decision instances during the evaluation + */ + long getExecutedDecisionInstances(); + /** * @return the number of executed decision elements during the evaluation */ diff --git a/engine-dmn/engine/src/main/java/org/camunda/bpm/dmn/engine/impl/DefaultDmnDecisionContext.java b/engine-dmn/engine/src/main/java/org/camunda/bpm/dmn/engine/impl/DefaultDmnDecisionContext.java index 145e029fac0..db95007d5ce 100644 --- a/engine-dmn/engine/src/main/java/org/camunda/bpm/dmn/engine/impl/DefaultDmnDecisionContext.java +++ b/engine-dmn/engine/src/main/java/org/camunda/bpm/dmn/engine/impl/DefaultDmnDecisionContext.java @@ -174,6 +174,7 @@ protected void generateDecisionEvaluationEvent(List requiredDecisionResults = new ArrayList(); + protected long executedDecisionInstances; protected long executedDecisionElements; + @Override public DmnDecisionLogicEvaluationEvent getDecisionResult() { return decisionResult; } @@ -37,6 +39,7 @@ public void setDecisionResult(DmnDecisionLogicEvaluationEvent decisionResult) { this.decisionResult = decisionResult; } + @Override public Collection getRequiredDecisionResults() { return requiredDecisionResults; } @@ -45,6 +48,16 @@ public void setRequiredDecisionResults(Collection callActivity.builder().camundaIn((String) name, (String) name)); + + return modelInstance; + } +} \ No newline at end of file diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/standalone/db/entitymanager/PurgeDatabaseTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/standalone/db/entitymanager/PurgeDatabaseTest.java index 988d262b83e..7ed81f800dc 100644 --- a/engine/src/test/java/org/camunda/bpm/engine/test/standalone/db/entitymanager/PurgeDatabaseTest.java +++ b/engine/src/test/java/org/camunda/bpm/engine/test/standalone/db/entitymanager/PurgeDatabaseTest.java @@ -199,7 +199,7 @@ public void testPurgeComplexProcess() { assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_JOBDEF")); assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_ID_USER")); assertEquals(5, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_EXECUTION")); - assertEquals(10, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_METER_LOG")); + assertEquals(12, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_METER_LOG")); assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_VARIABLE")); assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_PROCDEF")); assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_ID_TENANT"));