Changes for BAEL-1633
This commit is contained in:
@@ -3,11 +3,13 @@ package com.baeldung.spring.session;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracer.SpanInScope;
|
||||
|
||||
@Service
|
||||
public class SleuthService {
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
@@ -26,12 +28,12 @@ public class SleuthService {
|
||||
public void doSomeWorkNewSpan() throws InterruptedException {
|
||||
logger.info("I'm in the original span");
|
||||
|
||||
Span newSpan = tracer.createSpan("newSpan");
|
||||
try {
|
||||
Span newSpan = tracer.newTrace().name("newSpan").start();
|
||||
try (SpanInScope ws = tracer.withSpanInScope(newSpan.start())) {
|
||||
Thread.sleep(1000L);
|
||||
logger.info("I'm in the new span doing some cool work that needs its own span");
|
||||
} finally {
|
||||
tracer.close(newSpan);
|
||||
newSpan.finish();
|
||||
}
|
||||
|
||||
logger.info("I'm in the original span");
|
||||
|
||||
Reference in New Issue
Block a user