From 273a69e3405def0484f2ddf73774c9b5f5bf1340 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Tue, 15 Oct 2024 11:48:59 +0200 Subject: [PATCH] [Fix #3725] Setting leaveTime in Split and Fault node instance --- .../core/common/process/MetricsProcessEventListener.java | 2 +- .../java/org/jbpm/workflow/instance/node/FaultNodeInstance.java | 1 + .../java/org/jbpm/workflow/instance/node/SplitInstance.java | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/common/monitoring/core/src/main/java/org/kie/kogito/monitoring/core/common/process/MetricsProcessEventListener.java b/addons/common/monitoring/core/src/main/java/org/kie/kogito/monitoring/core/common/process/MetricsProcessEventListener.java index 007c1aa4bde..1de0307b1af 100644 --- a/addons/common/monitoring/core/src/main/java/org/kie/kogito/monitoring/core/common/process/MetricsProcessEventListener.java +++ b/addons/common/monitoring/core/src/main/java/org/kie/kogito/monitoring/core/common/process/MetricsProcessEventListener.java @@ -179,7 +179,7 @@ public void beforeNodeLeft(ProcessNodeLeftEvent event) { } private void recordNodeDuration(DistributionSummary summary, KogitoNodeInstance instance, TimeUnit target) { - if (instance.getTriggerTime() != null) { + if (instance.getTriggerTime() != null && instance.getLeaveTime() != null) { double duration = target.convert(instance.getLeaveTime().getTime() - instance.getTriggerTime().getTime(), TimeUnit.MILLISECONDS); summary.record(duration); LOGGER.debug("Recorded {} {} because of node {} for summary {}", duration, target, instance.getNode().getName(), summary.getId().getName()); diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/FaultNodeInstance.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/FaultNodeInstance.java index 2340848f7b0..ec8fa4b948f 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/FaultNodeInstance.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/FaultNodeInstance.java @@ -88,6 +88,7 @@ public void internalTrigger(KogitoNodeInstance from, String type) { if (getNode().getMetaData().get("hidden") != null) { hidden = true; } + leaveTime = new Date(); if (!hidden) { InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); ((InternalProcessRuntime) kruntime.getProcessRuntime()) diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/SplitInstance.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/SplitInstance.java index 5d6d2c4d61a..6319299d207 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/SplitInstance.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/SplitInstance.java @@ -230,6 +230,7 @@ protected void executeStrategy(Split split, String type) { if (getNode().getMetaData().get("hidden") != null) { hidden = true; } + leaveTime = new Date(); InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); if (!hidden) { ((InternalProcessRuntime) kruntime.getProcessRuntime())