/** * Loads all the data which is required for building the tree. */ private void prepare() { if (mode == Mode.SINGLE) { invocationSequences = Arrays.asList(invocationSequence); // loading all spans related to the set invocation sequence if (spanService != null) { Stream<InvocationSequenceData> invocationStream = InvocationSequenceDataHelper.asStream(invocationSequence); spans = invocationStream.map(i -> i.getSpanIdent()).filter(Objects::nonNull).map(spanService::get).filter(Objects::nonNull).collect(Collectors.toList()); } else { spans = new ArrayList<>(); } } else { if (traceId == null) { throw new IllegalStateException("A trace id have to be specified when a span tree has to be build and the mode is not set to SINGLE."); } spans = loadSpans(); if (mode == Mode.ALL) { invocationSequences = loadInvocationSequences(); } } if (mode != Mode.ONLY_SPANS_WITH_SDK) { spans.removeIf(s -> (s.getPropagationType() == null) && !s.isRoot()); } }