Performs minimal work to update to Brave 5.10 (#1573)

A later PR will handle new features/deprecation
This commit is contained in:
Adrian Cole
2020-02-26 16:43:14 +08:00
committed by GitHub
parent 0446918fcf
commit 7262790717
6 changed files with 39 additions and 19 deletions

View File

@@ -33,7 +33,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<spring-boot.version>2.3.0.BUILD-SNAPSHOT</spring-boot.version>
<brave.version>5.9.5</brave.version>
<brave.version>5.10.0</brave.version>
<okhttp.version>3.14.6</okhttp.version>
</properties>

View File

@@ -257,7 +257,7 @@
<spring-cloud-stream.version>Horsham.SR1</spring-cloud-stream.version>
<spring-cloud-netflix.version>2.2.2.BUILD-SNAPSHOT</spring-cloud-netflix.version>
<spring-cloud-openfeign.version>2.2.2.BUILD-SNAPSHOT</spring-cloud-openfeign.version>
<brave.version>5.9.5</brave.version>
<brave.version>5.10.0</brave.version>
<spring-security-boot-autoconfigure.version>2.1.7.RELEASE</spring-security-boot-autoconfigure.version>
<spring-cloud-aws.version>2.2.2.BUILD-SNAPSHOT</spring-cloud-aws.version>
<disable.nohttp.checks>false</disable.nohttp.checks>

View File

@@ -31,7 +31,7 @@
<name>spring-cloud-sleuth-dependencies</name>
<description>Spring Cloud Sleuth Dependencies</description>
<properties>
<brave.version>5.9.5</brave.version>
<brave.version>5.10.0</brave.version>
<brave.opentracing.version>0.35.1</brave.opentracing.version>
<grpc.spring.boot.version>3.4.1</grpc.spring.boot.version>
</properties>

View File

@@ -83,12 +83,6 @@ public class ReactorNettyHttpClientBraveTests
public void callbackContextIsFromInvocationTime() {
}
@Test
@Ignore("TODO: False negative due to NPE reading context: remove after Brave 5.10")
@Override
public void asyncRootSpan() {
}
@Test
@Ignore("TODO: reactor/reactor-netty#1000")
@Override
@@ -101,6 +95,13 @@ public class ReactorNettyHttpClientBraveTests
public void supportsPortableCustomization() {
}
@Test
@Ignore("TODO: reactor/reactor-netty#1000")
@Override
@Deprecated
public void supportsDeprecatedPortableCustomization() {
}
@Test
@Ignore("TODO: reactor/reactor-netty#1000")
@Override
@@ -119,6 +120,12 @@ public class ReactorNettyHttpClientBraveTests
public void httpPathTagExcludesQueryParams() {
}
@Test
@Ignore("HttpClient has no function to retrieve the wire request from the response")
@Override
public void readsRequestAtResponseTime() {
}
@Override
protected void post(AnnotationConfigApplicationContext context,
String pathIncludingQuery, String body) {
@@ -129,11 +136,11 @@ public class ReactorNettyHttpClientBraveTests
@Override
protected void getAsync(AnnotationConfigApplicationContext context, String path,
Callback<Void> callback) {
Callback<Integer> callback) {
Mono<HttpClientResponse> request = context.getBean(HttpClient.class).get()
.uri(path).response();
TestCallbackSubscriber.subscribe(request, callback);
TestHttpCallbackSubscriber.subscribe(request, r -> r.status().code(), callback);
}
}

View File

@@ -17,6 +17,7 @@
package org.springframework.cloud.sleuth.instrument.web.client;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import org.reactivestreams.Subscription;
import reactor.core.CoreSubscriber;
@@ -34,17 +35,22 @@ import zipkin2.Callback;
* The implementation forwards signals to the supplied {@link Callback}, enforcing
* assumptions about a non-empty, {@link Mono} subscription.
*/
final class TestCallbackSubscriber<T> implements CoreSubscriber<T> {
final class TestHttpCallbackSubscriber<T> implements CoreSubscriber<T> {
static <T> void subscribe(Mono<T> mono, Callback<Void> callback) {
mono.subscribe(new TestCallbackSubscriber<>(callback));
static <T> void subscribe(Mono<T> mono, Function<T, Integer> statusCodeFunction,
Callback<Integer> callback) {
mono.subscribe(new TestHttpCallbackSubscriber<>(statusCodeFunction, callback));
}
final Callback<Void> callback;
final Function<T, Integer> statusCodeFunction;
final Callback<Integer> callback;
final AtomicReference<Subscription> ref = new AtomicReference<>();
private TestCallbackSubscriber(Callback<Void> callback) {
private TestHttpCallbackSubscriber(Function<T, Integer> statusCodeFunction,
Callback<Integer> callback) {
this.statusCodeFunction = statusCodeFunction;
this.callback = callback;
}
@@ -63,7 +69,7 @@ final class TestCallbackSubscriber<T> implements CoreSubscriber<T> {
@Override
public void onNext(T t) {
if (ref.getAndSet(null) != null) {
callback.onSuccess(null /* because Void */);
callback.onSuccess(statusCodeFunction.apply(t));
}
else {
// This is a Mono, which doesn't signal onNext() twice. If we reach here,

View File

@@ -75,10 +75,11 @@ public class WebClientBraveTests
@Override
protected void getAsync(AnnotationConfigApplicationContext context, String path,
Callback<Void> callback) {
Callback<Integer> callback) {
Mono<ClientResponse> request = client(context).get().uri(path).exchange();
TestCallbackSubscriber.subscribe(request, callback);
TestHttpCallbackSubscriber.subscribe(request, ClientResponse::rawStatusCode,
callback);
}
@Test
@@ -93,6 +94,12 @@ public class WebClientBraveTests
public void reportsServerAddress() {
}
@Test
@Ignore("TODO: maybe refactor as an ExchangeFilterFunction to get the request from response")
@Override
public void readsRequestAtResponseTime() {
}
WebClient client(AnnotationConfigApplicationContext context) {
return context.getBean(WebClient.Builder.class)
.baseUrl("http://127.0.0.1:" + server.getPort()).build();