@Test public void testInstrumentedRunnable() { Runnable wrappedRunnable = mock(Runnable.class); SofaTracerRunnable runnable = new SofaTracerRunnable(wrappedRunnable, traceContext); runnable.run(); verify(traceContext, times(1)).getCurrentSpan(); verify(traceContext, times(1)).isEmpty(); verify(wrappedRunnable, times(1)).run(); verifyNoMoreInteractions(traceContext, wrappedRunnable); }
@Override public void run() { if (Thread.currentThread().getId() != tid) { if (currentSpan != null) { traceContext.push(currentSpan); SpanExtensionFactory.logStartedSpan(currentSpan); } } try { wrappedRunnable.run(); } finally { if (Thread.currentThread().getId() != tid) { if (currentSpan != null) { traceContext.pop(); } } } }
SofaTracerRunnable implements Runnable { @Override public void run() { if (Thread.currentThread().getId() != tid) { if (currentSpan != null) { traceContext.push(currentSpan); SpanExtensionFactory.logStartedSpan(currentSpan); } } try { wrappedRunnable.run(); } finally { if (Thread.currentThread().getId() != tid) { if (currentSpan != null) { traceContext.pop(); } } } } }
SofaTracerRunnable implements Runnable { @Override public void run() { if (Thread.currentThread().getId() != tid) { if (currentSpan != null) { traceContext.push(currentSpan); SpanExtensionFactory.logStartedSpan(currentSpan); } } try { wrappedRunnable.run(); } finally { if (Thread.currentThread().getId() != tid) { if (currentSpan != null) { traceContext.pop(); } } } } SofaTracerRunnable(Runnable wrappedRunnable);  SofaTracerRunnable(Runnable wrappedRunnable, SofaTraceContext traceContext); }
SofaTracerRunnable implements Runnable { @Override public void run() { if (Thread.currentThread().getId() != tid) { if (currentSpan != null) { traceContext.push(currentSpan); SpanExtensionFactory.logStartedSpan(currentSpan); } } try { wrappedRunnable.run(); } finally { if (Thread.currentThread().getId() != tid) { if (currentSpan != null) { traceContext.pop(); } } } } SofaTracerRunnable(Runnable wrappedRunnable);  SofaTracerRunnable(Runnable wrappedRunnable, SofaTraceContext traceContext); @Override void run(); }
SofaTracerRunnable implements Runnable { @Override public void run() { if (Thread.currentThread().getId() != tid) { if (currentSpan != null) { traceContext.push(currentSpan); SpanExtensionFactory.logStartedSpan(currentSpan); } } try { wrappedRunnable.run(); } finally { if (Thread.currentThread().getId() != tid) { if (currentSpan != null) { traceContext.pop(); } } } } SofaTracerRunnable(Runnable wrappedRunnable);  SofaTracerRunnable(Runnable wrappedRunnable, SofaTraceContext traceContext); @Override void run();  }