This commit is contained in:
于玉桔 2019-07-12 18:52:03 +08:00 committed by 吴晟 Wu Sheng
parent faec2b02b4
commit d996d7bf4a
3 changed files with 7 additions and 4 deletions

View File

@ -157,6 +157,10 @@ public class ContextManager implements BootService {
return get().awaitFinishAsync();
}
/**
* If not sure has the active span, use this method, will be cause NPE when has no active span,
* use ContextManager::isActive method to determine whether there has the active span.
*/
public static AbstractSpan activeSpan() {
return get().activeSpan();
}

View File

@ -92,7 +92,7 @@ class BaseInterceptorMethods {
}
void handleMethodException(Throwable t) {
if (ContextManager.activeSpan() != null) {
if (ContextManager.isActive()) {
ContextManager.activeSpan().errorOccurred().log(t);
}
}

View File

@ -42,9 +42,8 @@ public class FilteringWebHandlerInterceptor implements InstanceMethodsAroundInte
ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
Route route = exchange.getRequiredAttribute(GATEWAY_ROUTE_ATTR);
AbstractSpan span = ContextManager.activeSpan();
if (span != null) {
span.tag("route", route.getId());
if (ContextManager.isActive()) {
ContextManager.activeSpan().tag("route", route.getId());
}
}