public final Span joinSpan(TraceContext context) {
    if (context == null) throw new NullPointerException("context == null");
    if (!supportsJoin) return newChild(context);

    // set shared flag if not already done
    int flags = InternalPropagation.instance.flags(context);
    if (!context.shared()) {
      flags |= FLAG_SHARED;
      return toSpan(context, InternalPropagation.instance.withFlags(context, flags));
    } else {
      flags &= ~FLAG_SHARED;
      return toSpan(InternalPropagation.instance.withFlags(context, flags), context);
    }
  }
@Test void localRootId_joinSpan_notYetSampled() {
    TraceContext context1 = TraceContext.newBuilder().traceId(1).spanId(2).build();
    TraceContext context2 = TraceContext.newBuilder().traceId(1).spanId(3).build();
    localRootId(context1, context2, ctx -> tracer.joinSpan(ctx.context()));
  }