BraveScope newScope(BraveSpan span, boolean finishSpanOnClose) { BraveScope result = new BraveScope( this, tracer.withSpanInScope(span.delegate), span, finishSpanOnClose ); currentScopes.get().addFirst(result); return result; }
/** Attempts to get a span from the current api, falling back to brave's native one */ BraveSpan currentSpan() { BraveScope scope = currentScopes.get().peekFirst(); if (scope != null) { return scope.span(); } else { brave.Span braveSpan = tracer.currentSpan(); if (braveSpan != null) { return new BraveSpan(tracer, braveSpan); } } return null; }