Search in sources :

Example 1 with TraceHeader

use of org.kie.kogito.tracing.event.trace.TraceHeader in project kogito-runtimes by kiegroup.

the class DefaultAggregator method buildNotEnoughDataCloudEvent.

private static Optional<CloudEvent> buildNotEnoughDataCloudEvent(DMNModel model, String executionId, ConfigBean configBean) {
    TraceHeader header = new TraceHeader(TraceEventType.DMN, executionId, null, null, null, EventUtils.traceResourceIdFrom(configBean.getServiceUrl(), model), Stream.of(EventUtils.messageFrom(InternalMessageType.NOT_ENOUGH_DATA), model == null ? EventUtils.messageFrom(InternalMessageType.DMN_MODEL_NOT_FOUND) : null).filter(Objects::nonNull).collect(Collectors.toList()));
    TraceEvent event = new TraceEvent(header, Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
    return CloudEventUtils.build(executionId, buildSource(configBean.getServiceUrl(), null), event, TraceEvent.class);
}
Also used : TraceHeader(org.kie.kogito.tracing.event.trace.TraceHeader) Objects(java.util.Objects) TraceEvent(org.kie.kogito.tracing.event.trace.TraceEvent)

Example 2 with TraceHeader

use of org.kie.kogito.tracing.event.trace.TraceHeader in project kogito-apps by kiegroup.

the class TrustyServiceTestUtils method setExecutionId.

private static void setExecutionId(TraceEvent traceEvent, String executionId) {
    try {
        TraceHeader traceHeader = traceEvent.getHeader();
        Field member_name = traceHeader.getClass().getDeclaredField("executionId");
        member_name.setAccessible(true);
        member_name.set(traceHeader, executionId);
    } catch (IllegalAccessException | NoSuchFieldException e) {
        throw new RuntimeException("can't inject execution id in trace header");
    }
}
Also used : Field(java.lang.reflect.Field) TraceHeader(org.kie.kogito.tracing.event.trace.TraceHeader)

Example 3 with TraceHeader

use of org.kie.kogito.tracing.event.trace.TraceHeader 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);
}
Also used : TraceOutputValue(org.kie.kogito.tracing.event.trace.TraceOutputValue) TraceHeader(org.kie.kogito.tracing.event.trace.TraceHeader) ArrayList(java.util.ArrayList) List(java.util.List) TraceInputValue(org.kie.kogito.tracing.event.trace.TraceInputValue) EvaluateEvent(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent) TraceEvent(org.kie.kogito.tracing.event.trace.TraceEvent)

Aggregations

TraceHeader (org.kie.kogito.tracing.event.trace.TraceHeader)3 TraceEvent (org.kie.kogito.tracing.event.trace.TraceEvent)2 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 EvaluateEvent (org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent)1 TraceInputValue (org.kie.kogito.tracing.event.trace.TraceInputValue)1 TraceOutputValue (org.kie.kogito.tracing.event.trace.TraceOutputValue)1