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);
}
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");
}
}
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);
}
Aggregations