Moved to Brave Pom, removed double checking in WebClient

This commit is contained in:
Marcin Grzejszczak
2018-03-02 08:56:56 +01:00
parent 49840ea8da
commit 237593224a
3 changed files with 9 additions and 52 deletions

View File

@@ -192,6 +192,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-bom</artifactId>
<version>${brave.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Spock -->
<dependency>
<groupId>org.spockframework</groupId>
@@ -259,6 +266,7 @@
<spring-cloud-stream.version>Elmhurst.BUILD-SNAPSHOT</spring-cloud-stream.version>
<spring-cloud-netflix.version>2.0.0.BUILD-SNAPSHOT</spring-cloud-netflix.version>
<spring-cloud-openfeign.version>2.0.0.BUILD-SNAPSHOT</spring-cloud-openfeign.version>
<brave.version>4.16.3-SNAPSHOT</brave.version>
</properties>
<profiles>

View File

@@ -25,7 +25,6 @@ import brave.http.HttpClientHandler;
import brave.http.HttpTracing;
import brave.propagation.Propagation;
import brave.propagation.TraceContext;
import brave.propagation.TraceContextOrSamplingFlags;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
@@ -90,7 +89,6 @@ class TraceExchangeFilterFunction implements ExchangeFilterFunction {
private static final Log log = LogFactory.getLog(
TraceExchangeFilterFunction.class);
private static final String CLIENT_SPAN_KEY = "sleuth.webclient.clientSpan";
private static final String CLIENT_SPAN_ALREADY_PROCESSED_KEY = "sleuth.webclient.clientSpanAlreadyProcessed";
static final Propagation.Setter<ClientRequest.Builder, String> SETTER =
new Propagation.Setter<ClientRequest.Builder, String>() {
@@ -138,7 +136,6 @@ class TraceExchangeFilterFunction implements ExchangeFilterFunction {
.flatMap(anyAndContext -> {
Object any = anyAndContext.getT1();
Span clientSpan = anyAndContext.getT2().get(CLIENT_SPAN_KEY);
boolean clientSpanAlreadyProcessed = anyAndContext.getT2().get(CLIENT_SPAN_ALREADY_PROCESSED_KEY);
Mono<ClientResponse> continuation;
final Tracer.SpanInScope ws = tracer().withSpanInScope(clientSpan);
if (any instanceof Throwable) {
@@ -148,13 +145,6 @@ class TraceExchangeFilterFunction implements ExchangeFilterFunction {
}
return continuation.doAfterSuccessOrError(
(clientResponse, throwable1) -> {
if (clientSpanAlreadyProcessed) {
if (log.isDebugEnabled()) {
log.debug("Another component will process the response. Skipping");
ws.close();
return;
}
}
Throwable throwable = throwable1;
boolean error = clientResponse.statusCode().is4xxClientError() ||
clientResponse.statusCode().is5xxServerError();
@@ -177,14 +167,6 @@ class TraceExchangeFilterFunction implements ExchangeFilterFunction {
if (log.isDebugEnabled()) {
log.debug("Instrumenting WebClient call");
}
TraceContextOrSamplingFlags flags = httpTracing().tracing()
.propagation().extractor(GETTER).extract(request);
if (flags != TraceContextOrSamplingFlags.EMPTY) {
if (log.isDebugEnabled()) {
log.debug("The request was already instrumented. Will not do it again");
}
return c.put(CLIENT_SPAN_ALREADY_PROCESSED_KEY, true);
}
Span parent = c.getOrDefault(Span.class, null);
Span clientSpan = handler().handleSend(injector(), builder,
request, tracer().nextSpan());
@@ -197,8 +179,7 @@ class TraceExchangeFilterFunction implements ExchangeFilterFunction {
log.debug("Reactor Context got injected with the client span " + clientSpan);
}
}
return c.put(CLIENT_SPAN_ALREADY_PROCESSED_KEY, false)
.put(CLIENT_SPAN_KEY, clientSpan);
return c.put(CLIENT_SPAN_KEY, clientSpan);
});
return exchange;
}

View File

@@ -33,7 +33,6 @@
<zipkin.version>2.5.0</zipkin.version>
<zipkin-reporter.version>1.1.2</zipkin-reporter.version>
<zipkin-reporter2.version>2.3.3</zipkin-reporter2.version>
<brave.version>4.16.1</brave.version>
<brave.opentracing.version>0.28.0</brave.opentracing.version>
</properties>
<dependencyManagement>
@@ -83,37 +82,6 @@
<artifactId>spring-cloud-starter-sleuth</artifactId>
<version>${project.version}</version>
</dependency>
<!-- BRAVE -->
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave</artifactId>
<version>${brave.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-context-log4j2</artifactId>
<version>${brave.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-spring-web</artifactId>
<version>${brave.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-spring-webmvc</artifactId>
<version>${brave.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-httpclient</artifactId>
<version>${brave.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-httpasyncclient</artifactId>
<version>${brave.version}</version>
</dependency>
<!-- ZIPKIN -->
<dependency>
<groupId>io.zipkin.java</groupId>