Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ Span buildSpan(String operationName, RObject rObject) {
}


private <T> RFuture<T> continueScopeSpan(RFuture<T> redisFuture) {
Span span = tracer.activeSpan();
private <T> RFuture<T> continueScopeSpan(RFuture<T> redisFuture, Span span) {
CompletableRFuture<T> customRedisFuture = new CompletableRFuture<>(redisFuture);
redisFuture.whenComplete((v, throwable) -> {
try (Scope ignored = tracer.scopeManager().activate(span)) {
Expand Down Expand Up @@ -68,6 +67,6 @@ <V> RFuture<V> prepareRFuture(Span span, Supplier<RFuture<V>> futureSupplier) {
throw e;
}

return continueScopeSpan(setCompleteAction(future, span));
return continueScopeSpan(setCompleteAction(future, span), span);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import io.opentracing.Scope;
Expand All @@ -31,6 +31,8 @@
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import org.hamcrest.Matchers;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -182,7 +184,10 @@ public void async_continue_span() throws Exception {
System.out.println(
"active span: " + tracer.activeSpan() + " in thread: " + Thread.currentThread()
.getName());
assertSame(activeSpan, tracer.activeSpan());
final MockSpan actualSpan = (MockSpan)tracer.activeSpan();
assertEquals("containsKeyAsync", actualSpan.operationName());
assertEquals(Long.parseLong(activeSpan.context().toSpanId()), actualSpan.parentId());

return s;
}).get(15, TimeUnit.SECONDS));

Expand Down Expand Up @@ -218,8 +223,7 @@ public void test_config_span_name() throws Exception {

List<MockSpan> spans = tracer.finishedSpans();
assertEquals(2, spans.size());
MockSpan redisSpan = spans.get(0);
assertEquals("Redis.getAsync", redisSpan.operationName());
assertThat(spans, Matchers.hasItem(Matchers.hasToString(Matchers.containsString("Redis.getAsync"))));

assertNull(tracer.activeSpan());
customClient.shutdown();
Expand Down