Big refactor of sleuth core API
Instrumentation should be able to get by with only 2 interfaces: TraceManager and TraceAccessor (the former is not needed if you aren't starting a new Span). No explicit access to thread locals or manipulation of thread context is required (except locally where necessary). A Span is enclosed by a Trace (actually a view of the complete Trace that would be constructed remotely).
This commit is contained in:
@@ -21,7 +21,7 @@ import java.util.Random;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.sleuth.Trace;
|
||||
import org.springframework.cloud.sleuth.TraceManager;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.stereotype.Component;
|
||||
public class SampleBackground {
|
||||
|
||||
@Autowired
|
||||
private Trace trace;
|
||||
private TraceManager traceManager;
|
||||
|
||||
@SneakyThrows
|
||||
@Async
|
||||
@@ -40,7 +40,7 @@ public class SampleBackground {
|
||||
final Random random = new Random();
|
||||
int millis = random.nextInt(1000);
|
||||
Thread.sleep(millis);
|
||||
this.trace.addAnnotation("background-sleep-millis", String.valueOf(millis));
|
||||
this.traceManager.addAnnotation("background-sleep-millis", String.valueOf(millis));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user