Search in sources :

Example 1 with KogitoWorkItemNodeInstance

use of org.kie.kogito.internal.process.runtime.KogitoWorkItemNodeInstance in project kogito-runtimes by kiegroup.

the class MetricsProcessEventListener method beforeNodeLeft.

@Override
public void beforeNodeLeft(ProcessNodeLeftEvent event) {
    LOGGER.debug("Before Node left event: {}", event);
    final KogitoNodeInstance nodeInstance = (KogitoNodeInstance) event.getNodeInstance();
    if (nodeInstance instanceof KogitoWorkItemNodeInstance) {
        KogitoWorkItemNodeInstance wi = (KogitoWorkItemNodeInstance) nodeInstance;
        if (wi.getTriggerTime() != null) {
            final String name = (String) wi.getWorkItem().getParameters().getOrDefault("TaskName", wi.getWorkItem().getName());
            final double duration = millisToSeconds(wi.getLeaveTime().getTime() - wi.getTriggerTime().getTime());
            getWorkItemsDurationSummary(name).record(duration);
            LOGGER.debug("Work Item {}, duration: {}s", name, duration);
        }
    }
}
Also used : KogitoNodeInstance(org.kie.kogito.internal.process.runtime.KogitoNodeInstance) KogitoWorkItemNodeInstance(org.kie.kogito.internal.process.runtime.KogitoWorkItemNodeInstance)

Aggregations

KogitoNodeInstance (org.kie.kogito.internal.process.runtime.KogitoNodeInstance)1 KogitoWorkItemNodeInstance (org.kie.kogito.internal.process.runtime.KogitoWorkItemNodeInstance)1