Should detach span from trace filter for async; fixes #728

This commit is contained in:
Marcin Grzejszczak
2018-01-20 16:58:03 +01:00
parent 9056db494b
commit 2bd669cb2c
3 changed files with 5 additions and 12 deletions

View File

@@ -172,9 +172,9 @@ public class TraceFilter extends GenericFilterBean {
} finally {
if (isAsyncStarted(request) || request.isAsyncStarted()) {
if (log.isDebugEnabled()) {
log.debug("The span " + spanFromRequest + " will get detached by a HandleInterceptor");
log.debug("The span " + this.tracer.getCurrentSpan() + " will get detached");
}
// TODO: how to deal with response annotations and async?
this.tracer.detach(this.tracer.getCurrentSpan());
return;
}
detachOrCloseSpans(request, response, spanFromRequest, exception);

View File

@@ -68,6 +68,7 @@ public class TraceHandlerInterceptor extends HandlerInterceptorAdapter {
String spanName = spanName(handler);
boolean continueSpan = getRootSpanFromAttribute(request) != null;
Span span = continueSpan ? getRootSpanFromAttribute(request) : getTracer().createSpan(spanName);
getTracer().continueSpan(span);
if (log.isDebugEnabled()) {
log.debug("Handling span " + span);
}

View File

@@ -16,20 +16,12 @@
package org.springframework.cloud.sleuth.zipkin;
import org.assertj.core.api.Condition;
import org.junit.Ignore;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import zipkin.Constants;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.assertj.core.api.Condition;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,12 +34,12 @@ import org.springframework.cloud.sleuth.SpanReporter;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
import org.springframework.cloud.sleuth.zipkin.ZipkinSpanListenerTests.TestConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.test.context.junit4.SpringRunner;
import zipkin.Constants;
import zipkin.Endpoint;
import static org.assertj.core.api.Assertions.assertThat;