Fixed the build
This commit is contained in:
@@ -700,13 +700,16 @@ NOTE: The SLF4J MDC is always set and logback users immediately see the trace an
|
||||
shown earlier.
|
||||
Other logging systems have to configure their own formatter to get the same result.
|
||||
The default is as follows:
|
||||
`logging.pattern.level` set to `%5p [${spring.zipkin.service.name:${spring.application.name:-}},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}]`
|
||||
`logging.pattern.level` set to `%5p [${spring.zipkin.service.name:${spring.application.name:-}},%X{traceId:-},%X{spanId:-},%X{spanExportable:-}]`
|
||||
(this is a Spring Boot feature for logback users).
|
||||
If you do not use SLF4J, this pattern is NOT automatically applied.
|
||||
|
||||
IMPORTANT: Starting with version 3.0.0, the logging pattern has changed.
|
||||
We've converted the MDC entries from B3 to non B3 keys (e.g. `X-B3-TraceId` to `traceId`).
|
||||
|
||||
== Building
|
||||
|
||||
:jdkversion: 1.7
|
||||
:jdkversion: 1.8
|
||||
|
||||
=== Basic Compile and Test
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TraceEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
if (Boolean
|
||||
.parseBoolean(environment.getProperty("spring.sleuth.enabled", "true"))) {
|
||||
map.put("logging.pattern.level", "%5p [${spring.zipkin.service.name:"
|
||||
+ "${spring.application.name:}},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}]");
|
||||
+ "${spring.application.name:}},%X{traceId:-},%X{spanId:-},%X{spanExportable:-}]");
|
||||
}
|
||||
addOrReplace(environment.getPropertySources(), map);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import brave.Tracing;
|
||||
import brave.http.HttpRequest;
|
||||
import brave.sampler.Sampler;
|
||||
import brave.sampler.SamplerFunction;
|
||||
import feign.Client;
|
||||
import feign.Request;
|
||||
import feign.RequestTemplate;
|
||||
@@ -39,6 +41,7 @@ import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient;
|
||||
import org.springframework.cloud.sleuth.instrument.web.HttpClientSampler;
|
||||
import org.springframework.cloud.sleuth.util.ArrayListSpanReporter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -50,8 +53,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
@SpringBootTest(classes = Application.class,
|
||||
webEnvironment = SpringBootTest.WebEnvironment.NONE,
|
||||
properties = { "feign.hystrix.enabled=false" })
|
||||
webEnvironment = SpringBootTest.WebEnvironment.NONE)
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class ManuallyCreatedLoadBalancerFeignClientTests {
|
||||
|
||||
@@ -81,7 +83,7 @@ public class ManuallyCreatedLoadBalancerFeignClientTests {
|
||||
List<Span> spans = this.reporter.getSpans();
|
||||
// retries
|
||||
then(spans).hasSize(1);
|
||||
then(spans.get(0).tags().get("http.path")).isEqualTo("/");
|
||||
then(spans.get(0).tags().get("http.path")).isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -96,7 +98,7 @@ public class ManuallyCreatedLoadBalancerFeignClientTests {
|
||||
List<Span> spans = this.reporter.getSpans();
|
||||
// retries
|
||||
then(spans).hasSize(1);
|
||||
then(spans.get(0).tags().get("http.path")).isEqualTo("/");
|
||||
then(spans.get(0).tags().get("http.path")).isEqualTo("");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -121,6 +123,12 @@ class Application {
|
||||
return new ArrayListSpanReporter();
|
||||
}
|
||||
|
||||
@Bean(name = HttpClientSampler.NAME)
|
||||
@HttpClientSampler
|
||||
public SamplerFunction<HttpRequest> clientHttpSampler() {
|
||||
return arg -> true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MyBlockingClient extends FeignBlockingLoadBalancerClient {
|
||||
|
||||
@@ -21,7 +21,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import brave.Tracing;
|
||||
import brave.http.HttpRequest;
|
||||
import brave.sampler.Sampler;
|
||||
import brave.sampler.SamplerFunction;
|
||||
import feign.Client;
|
||||
import feign.Contract;
|
||||
import feign.Feign;
|
||||
@@ -41,6 +43,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
|
||||
import org.springframework.cloud.sleuth.instrument.web.HttpClientSampler;
|
||||
import org.springframework.cloud.sleuth.util.ArrayListSpanReporter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -53,8 +56,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
@SpringBootTest(classes = Application.class,
|
||||
webEnvironment = SpringBootTest.WebEnvironment.NONE,
|
||||
properties = { "feign.hystrix.enabled=false" })
|
||||
webEnvironment = SpringBootTest.WebEnvironment.NONE)
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class ManuallyCreatedDelegateLoadBalancerFeignClientTests {
|
||||
|
||||
@@ -89,7 +91,7 @@ public class ManuallyCreatedDelegateLoadBalancerFeignClientTests {
|
||||
List<Span> spans = this.reporter.getSpans();
|
||||
// retries
|
||||
then(spans).hasSize(1);
|
||||
then(spans.get(0).tags().get("http.path")).isEqualTo("/");
|
||||
then(spans.get(0).tags().get("http.path")).isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,7 +107,7 @@ public class ManuallyCreatedDelegateLoadBalancerFeignClientTests {
|
||||
List<Span> spans = this.reporter.getSpans();
|
||||
// retries
|
||||
then(spans).hasSize(1);
|
||||
then(spans.get(0).tags().get("http.path")).isEqualTo("/");
|
||||
then(spans.get(0).tags().get("http.path")).isEqualTo("");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -138,6 +140,12 @@ class Application {
|
||||
return new ArrayListSpanReporter();
|
||||
}
|
||||
|
||||
@Bean(name = HttpClientSampler.NAME)
|
||||
@HttpClientSampler
|
||||
public SamplerFunction<HttpRequest> clientHttpSampler() {
|
||||
return arg -> true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MyDelegateClient implements Client {
|
||||
|
||||
@@ -21,7 +21,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import brave.Tracing;
|
||||
import brave.http.HttpRequest;
|
||||
import brave.sampler.Sampler;
|
||||
import brave.sampler.SamplerFunction;
|
||||
import feign.Client;
|
||||
import feign.Request;
|
||||
import feign.RequestTemplate;
|
||||
@@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.sleuth.instrument.web.HttpClientSampler;
|
||||
import org.springframework.cloud.sleuth.util.ArrayListSpanReporter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -56,8 +59,7 @@ interface MyNameRemote {
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
@SpringBootTest(classes = Application.class,
|
||||
webEnvironment = SpringBootTest.WebEnvironment.NONE,
|
||||
properties = { "feign.hystrix.enabled=false" })
|
||||
webEnvironment = SpringBootTest.WebEnvironment.NONE)
|
||||
public class Issue502Tests {
|
||||
|
||||
@Autowired
|
||||
@@ -86,7 +88,7 @@ public class Issue502Tests {
|
||||
List<Span> spans = this.reporter.getSpans();
|
||||
// retries
|
||||
then(spans).hasSize(1);
|
||||
then(spans.get(0).tags().get("http.path")).isEqualTo("/");
|
||||
then(spans.get(0).tags().get("http.path")).isEqualTo("");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -111,6 +113,12 @@ class Application {
|
||||
return new ArrayListSpanReporter();
|
||||
}
|
||||
|
||||
@Bean(name = HttpClientSampler.NAME)
|
||||
@HttpClientSampler
|
||||
public SamplerFunction<HttpRequest> clientHttpSampler() {
|
||||
return arg -> true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MyClient implements Client {
|
||||
|
||||
@@ -342,7 +342,7 @@ public class TraceFilterIntegrationTests extends AbstractMvcIntegrationTest {
|
||||
|
||||
@RequestMapping("/ping")
|
||||
public String ping() {
|
||||
logger.info("ping");
|
||||
log.info("ping");
|
||||
span = this.tracer.currentSpan();
|
||||
return "ping";
|
||||
}
|
||||
@@ -354,7 +354,7 @@ public class TraceFilterIntegrationTests extends AbstractMvcIntegrationTest {
|
||||
|
||||
@RequestMapping("/deferred")
|
||||
public DeferredResult<String> deferredMethod() {
|
||||
logger.info("deferred");
|
||||
log.info("deferred");
|
||||
span = this.tracer.currentSpan();
|
||||
span.tag("tag", "value");
|
||||
DeferredResult<String> result = new DeferredResult<>();
|
||||
@@ -364,7 +364,7 @@ public class TraceFilterIntegrationTests extends AbstractMvcIntegrationTest {
|
||||
|
||||
@RequestMapping("/future")
|
||||
public CompletableFuture<String> future() {
|
||||
logger.info("future");
|
||||
log.info("future");
|
||||
return CompletableFuture.completedFuture("ping");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ import brave.http.HttpRequest;
|
||||
import brave.http.HttpRequestParser;
|
||||
import brave.sampler.Sampler;
|
||||
import brave.sampler.SamplerFunction;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -38,6 +40,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.system.CapturedOutput;
|
||||
import org.springframework.boot.test.system.OutputCaptureExtension;
|
||||
import org.springframework.cloud.sleuth.instrument.web.client.TraceWebClientAutoConfiguration;
|
||||
import org.springframework.cloud.sleuth.util.BlockingQueueSpanReporter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -104,6 +107,11 @@ public class TraceFilterWebIntegrationTests {
|
||||
"Request processing failed; nested exception is java.lang.RuntimeException: Throwing exception");
|
||||
// issue#714
|
||||
String hex = fromFirstTraceFilterFlow.traceId();
|
||||
thenLogsForExceptionLoggingFilterContainTracingInformation(capture, hex);
|
||||
}
|
||||
|
||||
private void thenLogsForExceptionLoggingFilterContainTracingInformation(
|
||||
CapturedOutput capture, String hex) {
|
||||
String[] split = capture.toString().split("\n");
|
||||
List<String> list = Arrays.stream(split)
|
||||
.filter(s -> s.contains("Uncaught exception thrown"))
|
||||
@@ -138,7 +146,7 @@ public class TraceFilterWebIntegrationTests {
|
||||
return this.environment.getProperty("local.server.port", Integer.class);
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@EnableAutoConfiguration(exclude = TraceWebClientAutoConfiguration.class)
|
||||
@Configuration
|
||||
public static class Config {
|
||||
|
||||
@@ -206,8 +214,11 @@ public class TraceFilterWebIntegrationTests {
|
||||
@RestController
|
||||
public static class GoodController {
|
||||
|
||||
private static final Log log = LogFactory.getLog(GoodController.class);
|
||||
|
||||
@RequestMapping("/good")
|
||||
public String beGood() {
|
||||
log.info("Good!");
|
||||
return "good";
|
||||
}
|
||||
|
||||
@@ -216,13 +227,18 @@ public class TraceFilterWebIntegrationTests {
|
||||
@RestController
|
||||
public static class ExceptionThrowingController {
|
||||
|
||||
private static final Log log = LogFactory
|
||||
.getLog(ExceptionThrowingController.class);
|
||||
|
||||
@RequestMapping("/")
|
||||
public void throwException() {
|
||||
log.info("Throws exception");
|
||||
throw new RuntimeException("Throwing exception");
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/test_bad_request", method = RequestMethod.GET)
|
||||
public ResponseEntity<?> processFail() {
|
||||
log.info("Test bad request");
|
||||
return ResponseEntity.badRequest().build();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,15 @@ import okhttp3.mockwebserver.Dispatcher;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.reactivestreams.Subscription;
|
||||
import reactor.core.publisher.BaseSubscriber;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import zipkin2.Callback;
|
||||
|
||||
import org.springframework.cloud.sleuth.instrument.reactor.TraceReactorAutoConfigurationAccessorConfiguration;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -46,6 +49,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
abstract class ITSpringConfiguredReactorClient
|
||||
extends ITHttpAsyncClient<AnnotationConfigApplicationContext> {
|
||||
|
||||
@BeforeAll
|
||||
@AfterAll
|
||||
public static void clear() {
|
||||
TraceReactorAutoConfigurationAccessorConfiguration.close();
|
||||
}
|
||||
|
||||
final Class<?>[] componentClasses;
|
||||
|
||||
/**
|
||||
|
||||
@@ -218,7 +218,7 @@ public class TraceWebFluxTests {
|
||||
@GetMapping("/api/c2/{id}")
|
||||
public Flux<String> successful(@PathVariable Long id) {
|
||||
// #786
|
||||
then(MDC.get("X-B3-TraceId")).isNotEmpty();
|
||||
then(MDC.get("traceId")).isNotEmpty();
|
||||
this.span = this.tracer.currentSpan();
|
||||
return Flux.just(id.toString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user