in common/src/main/java/co/elastic/otel/common/LocalRootSpan.java [60:80]
public static void onSpanStart(ReadableSpan startedSpan, Context parentContext) {
if (localRoot.get(startedSpan) != null) {
// early out: this method might be called by very many SpanProcessors,
// so it is likely good to have a fast early out check
return;
}
Span parent = Span.fromContext(parentContext);
SpanContext parentSpanCtx = parent.getSpanContext();
if (!parentSpanCtx.isValid()) {
localRoot.set(startedSpan, LOCAL_ROOT_MARKER);
} else if (parentSpanCtx.isRemote()) {
Boolean isInferred = startedSpan.getAttribute(ElasticAttributes.IS_INFERRED);
if (isInferred != null && isInferred) {
localRoot.set(startedSpan, INFERRED_SPAN_UNKNOWN_ROOT_MARKER);
} else {
localRoot.set(startedSpan, LOCAL_ROOT_MARKER);
}
} else {
localRoot.set(startedSpan, getFor(parent));
}
}