Add implementation for BAEL-5317.
This commit is contained in:
parent
19d7034d42
commit
fc36443ae2
|
@ -39,7 +39,7 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<spring-cloud-sleuth.version>2.0.2.RELEASE</spring-cloud-sleuth.version>
|
<spring-cloud-sleuth.version>3.1.0</spring-cloud-sleuth.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.baeldung.sleuth.traceid;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class SleuthCurrentTraceIdApp {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(SleuthCurrentTraceIdApp.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.baeldung.sleuth.traceid;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import brave.Span;
|
||||||
|
import brave.Tracer;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class SleuthTraceIdController {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(SleuthTraceIdController.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Tracer tracer;
|
||||||
|
|
||||||
|
@GetMapping("/hello")
|
||||||
|
public String hello() {
|
||||||
|
logger.info("Hello with Sleuth");
|
||||||
|
Span span = tracer.currentSpan();
|
||||||
|
if (span != null) {
|
||||||
|
logger.info("Span ID hex {}", span.context().spanIdString());
|
||||||
|
logger.info("Span ID decimal {}", span.context().spanId());
|
||||||
|
logger.info("Trace ID hex {}", span.context().traceIdString());
|
||||||
|
logger.info("Trace ID decimal {}", span.context().traceId());
|
||||||
|
}
|
||||||
|
return "hello";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.baeldung.sleuth.traceid;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = SleuthCurrentTraceIdApp.class)
|
||||||
|
public class CurrentTraceIdAppSpringContextTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,10 @@
|
||||||
package com.baeldung;
|
package com.baeldung.spring.session;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.baeldung.spring.session.SleuthWebApp;
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = SleuthWebApp.class)
|
@SpringBootTest(classes = SleuthWebApp.class)
|
||||||
public class SpringContextTest {
|
public class SpringContextTest {
|
Loading…
Reference in New Issue