未验证 提交 020a9953 编写于 作者: E Evan 提交者: GitHub

change spanId toolkit api type (#6216)

上级 cbfe7ee8
......@@ -46,12 +46,13 @@ public class TraceContext {
}
/**
* Try to get the spanId of current trace context.
* Try to get the spanId of current trace context. The spanId is a negative number when the trace context is
* missing.
*
* @return spanId, if it exists, or empty {@link String}.
*/
public static String spanId() {
return "";
public static int spanId() {
return -1;
}
/**
......
......@@ -74,7 +74,7 @@ public interface AbstractTracerContext {
*
* @return the string represents the id.
*/
String getSpanId();
int getSpanId();
/**
* Create an entry span
......
......@@ -70,7 +70,7 @@ public class ContextManager implements BootService {
}
/**
* @return the first global trace id if needEnhance. Otherwise, "N/A".
* @return the first global trace id when tracing. Otherwise, "N/A".
*/
public static String getGlobalTraceId() {
AbstractTracerContext context = CONTEXT.get();
......@@ -78,7 +78,7 @@ public class ContextManager implements BootService {
}
/**
* @return the current segment id if needEnhance. Otherwise, "N/A".
* @return the current segment id when tracing. Otherwise, "N/A".
*/
public static String getSegmentId() {
AbstractTracerContext context = CONTEXT.get();
......@@ -86,11 +86,11 @@ public class ContextManager implements BootService {
}
/**
* @return the current span id if needEnhance. Otherwise, "N/A".
* @return the current span id when tracing. Otherwise, the value is -1.
*/
public static String getSpanId() {
public static int getSpanId() {
AbstractTracerContext context = CONTEXT.get();
return Objects.nonNull(context) ? context.getSpanId() : EMPTY_TRACE_CONTEXT_ID;
return Objects.nonNull(context) ? context.getSpanId() : -1;
}
public static AbstractSpan createEntrySpan(String operationName, ContextCarrier carrier) {
......
......@@ -75,8 +75,8 @@ public class IgnoredTracerContext implements AbstractTracerContext {
}
@Override
public String getSpanId() {
return IGNORE_TRACE;
public int getSpanId() {
return -1;
}
@Override
......
......@@ -249,8 +249,8 @@ public class TracingContext implements AbstractTracerContext {
}
@Override
public String getSpanId() {
return String.valueOf(activeSpan().getSpanId());
public int getSpanId() {
return activeSpan().getSpanId();
}
/**
......
......@@ -46,12 +46,13 @@ public class TraceContext {
}
/**
* Try to get the spanId of current trace context.
* Try to get the spanId of current trace context. The spanId is a negative number when the trace context is
* missing.
*
* @return spanId, if it exists, or empty {@link String}.
*/
public static String spanId() {
return "";
public static int spanId() {
return -1;
}
/**
......
......@@ -61,7 +61,9 @@ public class TestController {
TraceContext.putCorrelation(CORRELATION_CONTEXT_KEY, CORRELATION_CONTEXT_VALUE);
ActiveSpan.tag("traceID", TraceContext.traceId());
ActiveSpan.tag("segmentID", TraceContext.segmentId());
ActiveSpan.tag("spanID", TraceContext.spanId());
if (TraceContext.spanId() > -1) {
ActiveSpan.tag("spanID", String.valueOf(TraceContext.spanId()));
}
testService.asyncCallable(() -> {
visit("http://localhost:8080/apm-toolkit-trace-scenario/case/asyncVisit/callable");
return true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册