Skip to content

Fix Redisson Async Tracing #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
@@ -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)) {
@@ -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
@@ -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;
@@ -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;
@@ -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));

@@ -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();