public Span startManual()

in geronimo-opentracing-common/src/main/java/org/apache/geronimo/microprofile/opentracing/common/impl/SpanBuilderImpl.java [119:140]


    public Span startManual() {
        if (timestamp < 0) {
            timestamp = TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis());
        }
        if (!ignoreActiveSpan && references.stream().noneMatch(it -> it.getType().equalsIgnoreCase(References.CHILD_OF))) {
            final Span span = tracer.activeSpan();
            if (span != null) {
                addReference(References.CHILD_OF, span.context());
            }
        }
        final ReferenceImpl parent = references.stream().filter(it -> References.CHILD_OF.equals(it.getType())).findFirst()
                .orElseGet(() -> references.isEmpty() ? null : references.iterator().next());
        final Map<String, String> baggages = references.stream()
                .flatMap(r -> StreamSupport.stream(
                        Spliterators.spliteratorUnknownSize(r.getValue().baggageItems().iterator(), Spliterator.IMMUTABLE),
                        false))
                .collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
        final SpanContextImpl context = parent == null ?
                tracer.newContext(idGenerator.next(), null, idGenerator.next(), baggages) :
                tracer.newContext(parent.getValue().getTraceId(), parent.getValue().getSpanId(), idGenerator.next(), baggages);
        return new SpanImpl(operationName, timestamp, references, tags, onFinish, context);
    }