use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DefaultAggregator method buildDefaultCloudEvent.
private static Optional<CloudEvent> buildDefaultCloudEvent(DMNModel model, String executionId, List<EvaluateEvent> events, ConfigBean configBean) {
EvaluateEvent firstEvent = events.get(0);
EvaluateEvent lastEvent = events.get(events.size() - 1);
List<TraceInputValue> inputs = buildTraceInputValues(model, firstEvent);
List<TraceOutputValue> outputs = buildTraceOutputValues(model, lastEvent);
Pair<List<TraceExecutionStep>, List<Message>> executionStepsPair = buildTraceExecutionSteps(model, executionId, events);
TraceHeader header = new TraceHeader(TraceEventType.DMN, executionId, firstEvent.getTimestamp(), lastEvent.getTimestamp(), computeDurationMillis(firstEvent, lastEvent), firstEvent.toTraceResourceId(configBean.getServiceUrl()), Stream.of(model == null ? Stream.of(EventUtils.messageFrom(InternalMessageType.DMN_MODEL_NOT_FOUND)) : Stream.<Message>empty(), executionStepsPair.getRight().stream(), lastEvent.getResult().getMessages().stream().filter(m -> m.getSourceId() == null || m.getSourceId().isEmpty())).flatMap(Function.identity()).collect(Collectors.toList()));
// complete event
TraceEvent event = new TraceEvent(header, inputs, outputs, executionStepsPair.getLeft());
return CloudEventUtils.build(executionId, buildSource(configBean.getServiceUrl(), firstEvent), event, TraceEvent.class);
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DefaultAggregator method buildTraceExecutionStep.
private static TraceExecutionStep buildTraceExecutionStep(DMNModel model, DefaultAggregatorStackEntry stackEntry, EvaluateEvent afterEvent) {
TraceExecutionStepType type = Optional.ofNullable(afterEvent.getType()).map(EvaluateEventType::toTraceExecutionStepType).orElse(null);
if (type == null) {
return null;
}
long duration = Optional.ofNullable(stackEntry).map(DefaultAggregatorStackEntry::getBeforeEvent).map(beforeEvent -> computeDurationMillis(beforeEvent, afterEvent)).orElse(0L);
List<TraceExecutionStep> children = Optional.ofNullable(stackEntry).map(DefaultAggregatorStackEntry::getChildren).orElse(Collections.emptyList());
switch(type) {
case DMN_BKM_EVALUATION:
case DMN_DECISION_SERVICE:
case DMN_BKM_INVOCATION:
return buildDefaultTraceExecutionStep(duration, afterEvent, children, type);
case DMN_CONTEXT_ENTRY:
return buildDmnContextEntryTraceExecutionStep(duration, afterEvent, children, model);
case DMN_DECISION:
return buildDmnDecisionTraceExecutionStep(duration, afterEvent, children);
case DMN_DECISION_TABLE:
return buildDmnDecisionTableTraceExecutionStep(duration, afterEvent, children, model);
default:
return null;
}
}
use of org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent in project kogito-runtimes by kiegroup.
the class DefaultAggregator method buildDmnDecisionTraceExecutionStep.
private static TraceExecutionStep buildDmnDecisionTraceExecutionStep(long duration, EvaluateEvent afterEvent, List<TraceExecutionStep> children) {
List<Message> messages = afterEvent.getResult().getMessages().stream().filter(m -> afterEvent.getNodeId().equals(m.getSourceId())).collect(Collectors.toList());
JsonNode result = afterEvent.getResult().getDecisionResults().stream().filter(dr -> dr.getDecisionId().equals(afterEvent.getNodeId())).findFirst().map(EvaluateDecisionResult::getResult).<JsonNode>map(EventUtils::jsonNodeFrom).orElse(null);
Map<String, String> additionalData = new HashMap<>();
additionalData.put(NODE_ID_KEY, afterEvent.getNodeId());
return new TraceExecutionStep(TraceExecutionStepType.DMN_DECISION, duration, afterEvent.getNodeName(), result, messages, additionalData, children);
}
Aggregations