Create a new method about getTraceSegmentId
This commit is contained in:
parent
bbe79aa865
commit
786f89f28e
|
|
@ -53,6 +53,18 @@ public enum ContextManager implements TracerContextListener {
|
|||
get().extract(carrier);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link TraceSegment#traceSegmentId} if exist. Otherwise, "N/A".
|
||||
*/
|
||||
public String getTraceSegmentId(){
|
||||
TracerContext segment = CONTEXT.get();
|
||||
if(segment == null){
|
||||
return "N/A";
|
||||
}else{
|
||||
return segment.getTraceSegmentId();
|
||||
}
|
||||
}
|
||||
|
||||
public Span createSpan(String operationName) {
|
||||
return get().createSpan(operationName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,6 +88,13 @@ public final class TracerContext {
|
|||
stopSpan(span, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current trace segment id.
|
||||
*/
|
||||
String getTraceSegmentId(){
|
||||
return segment.getTraceSegmentId();
|
||||
}
|
||||
|
||||
public void stopSpan(Span span, Long endTime){
|
||||
Span lastSpan = peek();
|
||||
if (lastSpan == span) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue