Search in sources :

Example 1 with TraceExecutionStepType

use of org.kie.kogito.tracing.event.trace.TraceExecutionStepType 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;
    }
}
Also used : TraceEventType(org.kie.kogito.tracing.event.trace.TraceEventType) TraceExecutionStepType(org.kie.kogito.tracing.event.trace.TraceExecutionStepType) Arrays(java.util.Arrays) DMNType(org.kie.dmn.api.core.DMNType) CloudEvent(io.cloudevents.CloudEvent) AFTER_EVALUATE_DECISION_SERVICE(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEventType.AFTER_EVALUATE_DECISION_SERVICE) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Deque(java.util.Deque) Function(java.util.function.Function) TraceExecutionStep(org.kie.kogito.tracing.event.trace.TraceExecutionStep) ArrayList(java.util.ArrayList) DecisionServiceNodeImpl(org.kie.dmn.core.ast.DecisionServiceNodeImpl) DMNModel(org.kie.dmn.api.core.DMNModel) DecisionNode(org.kie.dmn.api.core.ast.DecisionNode) DMNBaseNode(org.kie.dmn.core.ast.DMNBaseNode) Map(java.util.Map) EvaluateDecisionResult(org.kie.kogito.tracing.decision.event.evaluate.EvaluateDecisionResult) JsonNode(com.fasterxml.jackson.databind.JsonNode) URI(java.net.URI) InternalMessageType(org.kie.kogito.tracing.decision.message.InternalMessageType) Message(org.kie.kogito.tracing.event.message.Message) EvaluateEventType(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEventType) TraceEvent(org.kie.kogito.tracing.event.trace.TraceEvent) ConfigBean(org.kie.kogito.conf.ConfigBean) Logger(org.slf4j.Logger) DMNNode(org.kie.dmn.api.core.ast.DMNNode) EvaluateEvent(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent) TraceInputValue(org.kie.kogito.tracing.event.trace.TraceInputValue) TraceOutputValue(org.kie.kogito.tracing.event.trace.TraceOutputValue) Collection(java.util.Collection) EventUtils(org.kie.kogito.tracing.decision.event.EventUtils) Collectors(java.util.stream.Collectors) Pair(org.kie.dmn.feel.util.Pair) TypedValue(org.kie.kogito.tracing.typedvalue.TypedValue) Objects(java.util.Objects) List(java.util.List) TraceHeader(org.kie.kogito.tracing.event.trace.TraceHeader) Stream(java.util.stream.Stream) CloudEventUtils(org.kie.kogito.event.cloudevents.utils.CloudEventUtils) BEFORE_EVALUATE_DECISION_SERVICE(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEventType.BEFORE_EVALUATE_DECISION_SERVICE) Optional(java.util.Optional) InputDataNode(org.kie.dmn.api.core.ast.InputDataNode) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) TraceExecutionStepType(org.kie.kogito.tracing.event.trace.TraceExecutionStepType) TraceExecutionStep(org.kie.kogito.tracing.event.trace.TraceExecutionStep)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 CloudEvent (io.cloudevents.CloudEvent)1 URI (java.net.URI)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Deque (java.util.Deque)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 DMNModel (org.kie.dmn.api.core.DMNModel)1 DMNType (org.kie.dmn.api.core.DMNType)1 DMNNode (org.kie.dmn.api.core.ast.DMNNode)1