Polish
This commit is contained in:
@@ -57,9 +57,16 @@ public class SleuthWebProperties {
|
||||
|
||||
/**
|
||||
* Flag to toggle the presence of a filter that logs thrown exceptions.
|
||||
* @deprecated use {@link #exceptionLoggingFilterEnabled}
|
||||
*/
|
||||
@Deprecated
|
||||
private boolean exceptionThrowingFilterEnabled = true;
|
||||
|
||||
/**
|
||||
* Flag to toggle the presence of a filter that logs thrown exceptions.
|
||||
*/
|
||||
private boolean exceptionLoggingFilterEnabled = true;
|
||||
|
||||
/**
|
||||
* Properties related to HTTP clients.
|
||||
*/
|
||||
@@ -110,6 +117,14 @@ public class SleuthWebProperties {
|
||||
this.exceptionThrowingFilterEnabled = exceptionThrowingFilterEnabled;
|
||||
}
|
||||
|
||||
public boolean isExceptionLoggingFilterEnabled() {
|
||||
return this.exceptionLoggingFilterEnabled;
|
||||
}
|
||||
|
||||
public void setExceptionLoggingFilterEnabled(boolean exceptionLoggingFilterEnabled) {
|
||||
this.exceptionLoggingFilterEnabled = exceptionLoggingFilterEnabled;
|
||||
}
|
||||
|
||||
public Client getClient() {
|
||||
return this.client;
|
||||
}
|
||||
|
||||
@@ -81,8 +81,9 @@ public class TraceWebServletAutoConfiguration {
|
||||
return filterRegistrationBean;
|
||||
}
|
||||
|
||||
// TODO: Rename to exception-logging-filter for 3.0
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "spring.sleuth.web.exception-throwing-filter-enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.sleuth.web.exception-logging-filter-enabled", matchIfMissing = true)
|
||||
public FilterRegistrationBean exceptionThrowingFilter(
|
||||
SleuthWebProperties webProperties) {
|
||||
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(
|
||||
|
||||
@@ -259,10 +259,11 @@ final class TraceExchangeFilterFunction implements ExchangeFilterFunction {
|
||||
this.done = true;
|
||||
try {
|
||||
// decorate response body
|
||||
this.actual.onNext(ClientResponse.from(response)
|
||||
.body(response.bodyToFlux(DataBuffer.class)
|
||||
.transform(this.scopePassingTransformer))
|
||||
.build());
|
||||
this.actual
|
||||
.onNext(ClientResponse.from(response)
|
||||
.body(response.bodyToFlux(DataBuffer.class)
|
||||
.transform(this.scopePassingTransformer))
|
||||
.build());
|
||||
}
|
||||
finally {
|
||||
terminateSpan(response, null);
|
||||
@@ -304,8 +305,8 @@ final class TraceExchangeFilterFunction implements ExchangeFilterFunction {
|
||||
|
||||
void terminateSpanOnCancel() {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Subscription was cancelled. Will close the span [" + this.span
|
||||
+ "]");
|
||||
log.debug("Subscription was cancelled. Will close the span ["
|
||||
+ this.span + "]");
|
||||
}
|
||||
|
||||
this.span.tag("error", CANCELLED_SUBSCRIPTION_ERROR);
|
||||
@@ -316,8 +317,8 @@ final class TraceExchangeFilterFunction implements ExchangeFilterFunction {
|
||||
@Nullable Throwable throwable) {
|
||||
if (clientResponse == null || clientResponse.statusCode() == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("No response was returned. Will close the span [" + this.span
|
||||
+ "]");
|
||||
log.debug("No response was returned. Will close the span ["
|
||||
+ this.span + "]");
|
||||
}
|
||||
handleReceive(this.span, this.ws, clientResponse, throwable);
|
||||
return;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SleuthTagPropagationAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "spring.sleuth.propagation.tag.whitelisted-keys")
|
||||
public FinishedSpanHandler finishedSpanHandler(SleuthProperties sleuthProperties,
|
||||
SleuthTagPropagationProperties tagPropagationProperties) {
|
||||
SleuthTagPropagationProperties tagPropagationProperties) {
|
||||
return new TagPropagationFinishedSpanHandler(sleuthProperties,
|
||||
tagPropagationProperties);
|
||||
}
|
||||
|
||||
@@ -43,16 +43,17 @@ public class TagPropagationFinishedSpanHandler extends FinishedSpanHandler {
|
||||
private final SleuthTagPropagationProperties tagPropagationProperties;
|
||||
|
||||
public TagPropagationFinishedSpanHandler(SleuthProperties sleuthProperties,
|
||||
SleuthTagPropagationProperties tagPropagationProperties) {
|
||||
SleuthTagPropagationProperties tagPropagationProperties) {
|
||||
this.sleuthProperties = sleuthProperties;
|
||||
this.tagPropagationProperties = tagPropagationProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(TraceContext context, MutableSpan span) {
|
||||
Stream.of(this.sleuthProperties.getBaggageKeys(), this.sleuthProperties.getPropagationKeys())
|
||||
.flatMap(Collection::stream)
|
||||
.filter(key -> this.tagPropagationProperties.getWhitelistedKeys().contains(key))
|
||||
Stream.of(this.sleuthProperties.getBaggageKeys(),
|
||||
this.sleuthProperties.getPropagationKeys()).flatMap(Collection::stream)
|
||||
.filter(key -> this.tagPropagationProperties.getWhitelistedKeys()
|
||||
.contains(key))
|
||||
.map(baggageItemKey -> new AbstractMap.SimpleEntry<>(baggageItemKey,
|
||||
ExtraFieldPropagation.get(context, baggageItemKey)))
|
||||
.filter(entry -> nonNull(entry.getValue()))
|
||||
|
||||
@@ -624,7 +624,8 @@ public class SleuthSpanCreatorAspectMonoTests {
|
||||
|
||||
@Override
|
||||
public Mono<Long> newSpanInSubscriberContext() {
|
||||
return Mono.subscriberContext().flatMap(context -> Mono.just(id(this.tracer)));
|
||||
return Mono.subscriberContext()
|
||||
.flatMap(context -> Mono.just(id(this.tracer)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -643,8 +644,9 @@ public class SleuthSpanCreatorAspectMonoTests {
|
||||
@NewSpan(name = "outerSpanInTraceContext")
|
||||
public Mono<Pair<Pair<Long, Long>, Long>> outerNewSpanInTraceContext() {
|
||||
return Mono.defer(() -> Mono.just(id(this.tracer))
|
||||
.zipWith(this.testBeanInterface.newSpanInTraceContext()).map(pair -> Pair
|
||||
.of(Pair.of(pair.getT1(), id(this.tracer)), pair.getT2())));
|
||||
.zipWith(this.testBeanInterface.newSpanInTraceContext())
|
||||
.map(pair -> Pair.of(Pair.of(pair.getT1(), id(this.tracer)),
|
||||
pair.getT2())));
|
||||
}
|
||||
|
||||
@NewSpan(name = "outerSpanInSubscriberContext")
|
||||
|
||||
@@ -58,7 +58,8 @@ public class SpanTagAnnotationHandlerTests {
|
||||
.getMethod("getAnnotationForTagValueResolver", String.class);
|
||||
Annotation annotation = method.getParameterAnnotations()[0][0];
|
||||
if (annotation instanceof SpanTag) {
|
||||
String resolvedValue = this.handler.resolveTagValue((SpanTag) annotation, "test");
|
||||
String resolvedValue = this.handler.resolveTagValue((SpanTag) annotation,
|
||||
"test");
|
||||
assertThat(resolvedValue).isEqualTo("Value from myCustomTagValueResolver");
|
||||
}
|
||||
else {
|
||||
@@ -73,7 +74,8 @@ public class SpanTagAnnotationHandlerTests {
|
||||
.getMethod("getAnnotationForTagValueExpression", String.class);
|
||||
Annotation annotation = method.getParameterAnnotations()[0][0];
|
||||
if (annotation instanceof SpanTag) {
|
||||
String resolvedValue = this.handler.resolveTagValue((SpanTag) annotation, "test");
|
||||
String resolvedValue = this.handler.resolveTagValue((SpanTag) annotation,
|
||||
"test");
|
||||
|
||||
assertThat(resolvedValue).isEqualTo("hello characters");
|
||||
}
|
||||
|
||||
@@ -19,30 +19,30 @@ public class TraceAutoConfigurationPropagationCustomizationTests {
|
||||
@Test
|
||||
public void stillCreatesDefault() {
|
||||
this.contextRunner.run((context) -> {
|
||||
BDDAssertions.then(context.getBean(Propagation.Factory.class))
|
||||
.isEqualTo(B3Propagation.FACTORY);
|
||||
});
|
||||
BDDAssertions.then(context.getBean(Propagation.Factory.class))
|
||||
.isEqualTo(B3Propagation.FACTORY);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowsCustomization() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.sleuth.baggage-keys=my-baggage")
|
||||
this.contextRunner.withPropertyValues("spring.sleuth.baggage-keys=my-baggage")
|
||||
.run((context) -> {
|
||||
BDDAssertions.then(context.getBean(Propagation.Factory.class))
|
||||
.hasFieldOrPropertyWithValue("delegate", B3Propagation.FACTORY);
|
||||
.hasFieldOrPropertyWithValue("delegate",
|
||||
B3Propagation.FACTORY);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowsCustomizationOfBuilder() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.sleuth.baggage-keys=my-baggage")
|
||||
this.contextRunner.withPropertyValues("spring.sleuth.baggage-keys=my-baggage")
|
||||
.withUserConfiguration(CustomPropagationFactoryBuilderConfig.class)
|
||||
.run((context) -> {
|
||||
BDDAssertions.then(context.getBean(Propagation.Factory.class))
|
||||
.hasFieldOrPropertyWithValue("delegate", B3SinglePropagation.FACTORY);
|
||||
});
|
||||
.hasFieldOrPropertyWithValue("delegate",
|
||||
B3SinglePropagation.FACTORY);
|
||||
});
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -269,7 +269,8 @@ public class SpringCloudSleuthDocTests {
|
||||
"calculateTax");
|
||||
// Wrapping `Runnable` with `Tracing`. That way the current span will be available
|
||||
// in the thread of `Runnable`
|
||||
Runnable traceRunnableFromTracer = this.tracing.currentTraceContext().wrap(runnable);
|
||||
Runnable traceRunnableFromTracer = this.tracing.currentTraceContext()
|
||||
.wrap(runnable);
|
||||
// end::trace_runnable[]
|
||||
|
||||
then(traceRunnable).isExactlyInstanceOf(TraceRunnable.class);
|
||||
@@ -291,8 +292,8 @@ public class SpringCloudSleuthDocTests {
|
||||
}
|
||||
};
|
||||
// Manual `TraceCallable` creation with explicit "calculateTax" Span name
|
||||
Callable<String> traceCallable = new TraceCallable<>(this.tracing, spanNamer, callable,
|
||||
"calculateTax");
|
||||
Callable<String> traceCallable = new TraceCallable<>(this.tracing, spanNamer,
|
||||
callable, "calculateTax");
|
||||
// Wrapping `Callable` with `Tracing`. That way the current span will be available
|
||||
// in the thread of `Callable`
|
||||
Callable<String> traceCallableFromTracer = this.tracing.currentTraceContext()
|
||||
|
||||
@@ -117,17 +117,15 @@ public class ITTracingChannelInterceptor implements MessageHandler {
|
||||
this.directChannel.send(MessageBuilder.withPayload("hi")
|
||||
.setHeader("stompCommand", "DISCONNECT").build());
|
||||
|
||||
assertThat(
|
||||
MessageHeaderAccessor.getAccessor(this.message, MessageHeaderAccessor.class))
|
||||
.isNotNull();
|
||||
assertThat(MessageHeaderAccessor.getAccessor(this.message,
|
||||
MessageHeaderAccessor.class)).isNotNull();
|
||||
|
||||
this.message = null;
|
||||
this.directChannel.send(MessageBuilder.withPayload("hi")
|
||||
.setHeader("simpMessageType", "sth").build());
|
||||
|
||||
assertThat(
|
||||
MessageHeaderAccessor.getAccessor(this.message, MessageHeaderAccessor.class))
|
||||
.isNotNull();
|
||||
assertThat(MessageHeaderAccessor.getAccessor(this.message,
|
||||
MessageHeaderAccessor.class)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -135,9 +133,8 @@ public class ITTracingChannelInterceptor implements MessageHandler {
|
||||
this.directChannel
|
||||
.send(MessageBuilder.withPayload("hi").setHeader("foo", "bar").build());
|
||||
|
||||
assertThat(
|
||||
MessageHeaderAccessor.getAccessor(this.message, MessageHeaderAccessor.class))
|
||||
.isNull();
|
||||
assertThat(MessageHeaderAccessor.getAccessor(this.message,
|
||||
MessageHeaderAccessor.class)).isNull();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -187,8 +187,8 @@ public class TracingChannelInterceptorTest {
|
||||
|
||||
assertThat(messages.get(0).getHeaders()).doesNotContainKeys("X-B3-TraceId",
|
||||
"X-B3-SpanId", "X-B3-Sampled", "nativeHeaders");
|
||||
assertThat(this.spans).flatExtracting(Span::kind).containsExactly(Span.Kind.CONSUMER,
|
||||
null);
|
||||
assertThat(this.spans).flatExtracting(Span::kind)
|
||||
.containsExactly(Span.Kind.CONSUMER, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,8 +242,8 @@ public class TracingChannelInterceptorTest {
|
||||
|
||||
channel.send(MessageBuilder.withPayload("foo").build());
|
||||
|
||||
assertThat(this.spans).flatExtracting(Span::kind).containsExactly(Span.Kind.CONSUMER,
|
||||
null, Span.Kind.PRODUCER);
|
||||
assertThat(this.spans).flatExtracting(Span::kind)
|
||||
.containsExactly(Span.Kind.CONSUMER, null, Span.Kind.PRODUCER);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -178,8 +178,8 @@ public class BraveTracerTest {
|
||||
try (Scope scopeB = this.opentracing.buildSpan("spanB").startActive(false)) {
|
||||
idOfSpanB = getTraceContext(scopeB).spanId();
|
||||
parentIdOfSpanB = getTraceContext(scopeB).parentId();
|
||||
shouldBeIdOfSpanB = getTraceContext(this.opentracing.scopeManager().active())
|
||||
.spanId();
|
||||
shouldBeIdOfSpanB = getTraceContext(
|
||||
this.opentracing.scopeManager().active()).spanId();
|
||||
}
|
||||
shouldBeIdOfSpanA = getTraceContext(this.opentracing.scopeManager().active())
|
||||
.spanId();
|
||||
@@ -212,7 +212,8 @@ public class BraveTracerTest {
|
||||
Long idOfSpanA = spanA.context().spanId();
|
||||
try (SpanInScope scopeA = this.brave.tracer().withSpanInScope(spanA)) {
|
||||
|
||||
Span spanB = this.brave.tracer().newChild(spanA.context()).name("spanB").start();
|
||||
Span spanB = this.brave.tracer().newChild(spanA.context()).name("spanB")
|
||||
.start();
|
||||
idOfSpanB = spanB.context().spanId();
|
||||
parentIdOfSpanB = spanB.context().parentId();
|
||||
try (SpanInScope scopeB = this.brave.tracer().withSpanInScope(spanB)) {
|
||||
@@ -224,7 +225,8 @@ public class BraveTracerTest {
|
||||
|
||||
shouldBeIdOfSpanA = this.brave.currentTraceContext().get().spanId();
|
||||
|
||||
Span spanC = this.brave.tracer().newChild(spanA.context()).name("spanC").start();
|
||||
Span spanC = this.brave.tracer().newChild(spanA.context()).name("spanC")
|
||||
.start();
|
||||
parentIdOfSpanC = spanC.context().parentId();
|
||||
try (SpanInScope scopeC = this.brave.tracer().withSpanInScope(spanC)) {
|
||||
// nothing to do here
|
||||
@@ -277,7 +279,8 @@ public class BraveTracerTest {
|
||||
@Test
|
||||
public void implicitParentFromSpanManager_start_ignoreActiveSpan() {
|
||||
try (Scope scopeA = this.opentracing.buildSpan("spanA").startActive(true)) {
|
||||
BraveSpan span = this.opentracing.buildSpan("spanB").ignoreActiveSpan().start();
|
||||
BraveSpan span = this.opentracing.buildSpan("spanB").ignoreActiveSpan()
|
||||
.start();
|
||||
assertThat(span.unwrap().context().parentId()).isNull(); // new trace
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ public class ScopePassingSpanSubscriberTests {
|
||||
Span span = this.tracing.tracer().nextSpan();
|
||||
try (Tracer.SpanInScope ws = this.tracing.tracer()
|
||||
.withSpanInScope(span.start())) {
|
||||
CoreSubscriber<?> subscriber = ReactorSleuth
|
||||
.scopePassingSpanSubscription(this.tracing, new BaseSubscriber<Object>() {
|
||||
CoreSubscriber<?> subscriber = ReactorSleuth.scopePassingSpanSubscription(
|
||||
this.tracing, new BaseSubscriber<Object>() {
|
||||
});
|
||||
|
||||
then(subscriber.currentContext().get(Span.class)).isEqualTo(span);
|
||||
|
||||
@@ -253,8 +253,8 @@ public class SpanSubscriberTests {
|
||||
final AtomicReference<Long> spanInZipOperation = new AtomicReference<>();
|
||||
|
||||
try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(initSpan)) {
|
||||
Mono.fromCallable(this.tracer::currentSpan).map(span -> span.context().spanId())
|
||||
.doOnNext(spanInOperation::set)
|
||||
Mono.fromCallable(this.tracer::currentSpan)
|
||||
.map(span -> span.context().spanId()).doOnNext(spanInOperation::set)
|
||||
.zipWith(Mono.fromCallable(this.tracer::currentSpan)
|
||||
.map(span -> span.context().spanId())
|
||||
.doOnNext(spanInZipOperation::set))
|
||||
|
||||
@@ -182,8 +182,8 @@ class Reservation {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Reservation{" + "id=" + this.id + ", reservationName='" + this.reservationName
|
||||
+ '\'' + '}';
|
||||
return "Reservation{" + "id=" + this.id + ", reservationName='"
|
||||
+ this.reservationName + '\'' + '}';
|
||||
}
|
||||
|
||||
Reservation() {// why JPA why???
|
||||
|
||||
@@ -552,8 +552,8 @@ class TestBean {
|
||||
log.info("New Span in Subscriber Context");
|
||||
return Mono.subscriberContext()
|
||||
.doOnSuccess(context -> log.info("New Span in deferred Trace Context"))
|
||||
.flatMap(context -> Mono
|
||||
.defer(() -> Mono.just(this.tracer.currentSpan().context().spanId())));
|
||||
.flatMap(context -> Mono.defer(
|
||||
() -> Mono.just(this.tracer.currentSpan().context().spanId())));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,25 +31,22 @@ public class TraceWebServletAutoConfigurationTests {
|
||||
private static final String EXCEPTION_LOGGING_FILTER_BEAN_NAME = "exceptionThrowingFilter";
|
||||
|
||||
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(
|
||||
TraceAutoConfiguration.class,
|
||||
TraceHttpAutoConfiguration.class,
|
||||
TraceWebAutoConfiguration.class,
|
||||
TraceWebServletAutoConfiguration.class
|
||||
));
|
||||
.withConfiguration(AutoConfigurations.of(TraceAutoConfiguration.class,
|
||||
TraceHttpAutoConfiguration.class, TraceWebAutoConfiguration.class,
|
||||
TraceWebServletAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void shouldCreateExceptionLoggingFilterBeanByDefault() {
|
||||
this.contextRunner
|
||||
.run((context) -> {
|
||||
assertThat(context).hasBean(EXCEPTION_LOGGING_FILTER_BEAN_NAME);
|
||||
});
|
||||
this.contextRunner.run((context) -> {
|
||||
assertThat(context).hasBean(EXCEPTION_LOGGING_FILTER_BEAN_NAME);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateExceptionLoggingFilterBeanIfExplicitlyEnabled() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.sleuth.web.exception-throwing-filter-enabled=true")
|
||||
.withPropertyValues(
|
||||
"spring.sleuth.web.exception-logging-filter-enabled=true")
|
||||
.run((context) -> {
|
||||
assertThat(context).hasBean(EXCEPTION_LOGGING_FILTER_BEAN_NAME);
|
||||
});
|
||||
@@ -58,18 +55,23 @@ public class TraceWebServletAutoConfigurationTests {
|
||||
@Test
|
||||
public void shouldNotCreateExceptionLoggingFilterBeanIfDisabledInProperties() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.sleuth.web.exception-throwing-filter-enabled=false")
|
||||
.withPropertyValues(
|
||||
"spring.sleuth.web.exception-logging-filter-enabled=false")
|
||||
.run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(EXCEPTION_LOGGING_FILTER_BEAN_NAME);
|
||||
assertThat(context)
|
||||
.doesNotHaveBean(EXCEPTION_LOGGING_FILTER_BEAN_NAME);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotCreateExceptionLoggingFilterBeanIfDisabledInPropertiesUsingCamelCase() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.sleuth.web.exceptionThrowingFilterEnabled=false")
|
||||
.withPropertyValues(
|
||||
"spring.sleuth.web.exceptionLoggingFilterEnabled=false")
|
||||
.run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(EXCEPTION_LOGGING_FILTER_BEAN_NAME);
|
||||
assertThat(context)
|
||||
.doesNotHaveBean(EXCEPTION_LOGGING_FILTER_BEAN_NAME);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -102,8 +102,8 @@ public class MultipleAsyncRestTemplateTests {
|
||||
Span span = this.tracer.nextSpan().name("foo");
|
||||
try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(span.start())) {
|
||||
String result = this.asyncRestTemplate
|
||||
.getForEntity("http://localhost:" + this.port + "/foo", String.class).get()
|
||||
.getBody();
|
||||
.getForEntity("http://localhost:" + this.port + "/foo", String.class)
|
||||
.get().getBody();
|
||||
then(span.context().traceIdString()).isEqualTo(result);
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -111,7 +111,8 @@ public class FeignRetriesTests {
|
||||
// with the second retry (first retry) we send back good result
|
||||
return Response.builder().status(200).reason("OK")
|
||||
.headers(new HashMap<>()).body("OK", Charset.defaultCharset())
|
||||
.request(Request.create(Request.HttpMethod.POST, "/foo", new HashMap<>(), Request.Body.empty()))
|
||||
.request(Request.create(Request.HttpMethod.POST, "/foo",
|
||||
new HashMap<>(), Request.Body.empty()))
|
||||
.build();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -191,7 +191,8 @@ class CustomConfig {
|
||||
public Exception decode(String methodKey, Response response) {
|
||||
this.feignComponentAsserter.executedComponents.put(ErrorDecoder.class, true);
|
||||
if (response.status() == 409) {
|
||||
return new RetryableException("Article not Ready", Request.HttpMethod.GET, new Date());
|
||||
return new RetryableException("Article not Ready", Request.HttpMethod.GET,
|
||||
new Date());
|
||||
}
|
||||
else {
|
||||
return super.decode(methodKey, response);
|
||||
|
||||
@@ -122,7 +122,8 @@ class MyClient implements Client {
|
||||
public Response execute(Request request, Request.Options options) throws IOException {
|
||||
this.wasCalled = true;
|
||||
return Response.builder().body("foo", Charset.forName("UTF-8"))
|
||||
.request(Request.create(Request.HttpMethod.POST, "/foo", new HashMap<>(), Request.Body.empty()))
|
||||
.request(Request.create(Request.HttpMethod.POST, "/foo", new HashMap<>(),
|
||||
Request.Body.empty()))
|
||||
.headers(new HashMap<>()).status(200).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -311,7 +311,8 @@ public class WebClientTests {
|
||||
|
||||
try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(span)) {
|
||||
String response = this.httpClientBuilder.build().execute(
|
||||
new HttpGet("http://localhost:" + this.port), new BasicResponseHandler());
|
||||
new HttpGet("http://localhost:" + this.port),
|
||||
new BasicResponseHandler());
|
||||
|
||||
then(response).isNotEmpty();
|
||||
}
|
||||
|
||||
@@ -22,38 +22,39 @@ import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class SleuthTagPropagationAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(SleuthTagPropagationAutoConfiguration.class));
|
||||
.withConfiguration(
|
||||
AutoConfigurations.of(SleuthTagPropagationAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void shouldNotCreateHandler() {
|
||||
this.contextRunner
|
||||
.run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(TagPropagationFinishedSpanHandler.class);
|
||||
});
|
||||
this.contextRunner.run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(TagPropagationFinishedSpanHandler.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotCreateHandlerByDisablingIt() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.sleuth.propagation.tag.whitelisted-keys=some-key")
|
||||
.withPropertyValues(
|
||||
"spring.sleuth.propagation.tag.whitelisted-keys=some-key")
|
||||
.withPropertyValues("spring.sleuth.propagation.tag.enabled=false")
|
||||
.withUserConfiguration(TraceAutoConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).doesNotHaveBean(TagPropagationFinishedSpanHandler.class);
|
||||
.withUserConfiguration(TraceAutoConfiguration.class).run((context) -> {
|
||||
assertThat(context)
|
||||
.doesNotHaveBean(TagPropagationFinishedSpanHandler.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateHandler() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.sleuth.propagation.tag.whitelisted-keys=some-key")
|
||||
.withUserConfiguration(TraceAutoConfiguration.class)
|
||||
.run((context) -> {
|
||||
assertThat(context).hasSingleBean(TagPropagationFinishedSpanHandler.class);
|
||||
.withPropertyValues(
|
||||
"spring.sleuth.propagation.tag.whitelisted-keys=some-key")
|
||||
.withUserConfiguration(TraceAutoConfiguration.class).run((context) -> {
|
||||
assertThat(context)
|
||||
.hasSingleBean(TagPropagationFinishedSpanHandler.class);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -44,14 +44,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, properties = {
|
||||
"spring.sleuth.baggage-keys=my-baggage",
|
||||
"spring.sleuth.propagation-keys=my-propagation,others-propagation",
|
||||
"spring.sleuth.propagation.tag.whitelisted-keys=my-baggage,my-propagation"},
|
||||
classes = TagPropagationFinishedSpanHandlerTest.TestConfiguration.class)
|
||||
"spring.sleuth.propagation.tag.whitelisted-keys=my-baggage,my-propagation" }, classes = TagPropagationFinishedSpanHandlerTest.TestConfiguration.class)
|
||||
public class TagPropagationFinishedSpanHandlerTest {
|
||||
|
||||
private static final String BAGGAGE_KEY = "my-baggage";
|
||||
|
||||
private static final String BAGGAGE_VALUE = "332323";
|
||||
|
||||
private static final String PROPAGATION_KEY = "my-propagation";
|
||||
|
||||
private static final String PROPAGATION_VALUE = "332323";
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user