提交 d996d7bf 编写于 作者: 于玉桔 提交者: wu-sheng

fix (#3057)

上级 faec2b02
...@@ -157,6 +157,10 @@ public class ContextManager implements BootService { ...@@ -157,6 +157,10 @@ public class ContextManager implements BootService {
return get().awaitFinishAsync(); 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() { public static AbstractSpan activeSpan() {
return get().activeSpan(); return get().activeSpan();
} }
......
...@@ -92,7 +92,7 @@ class BaseInterceptorMethods { ...@@ -92,7 +92,7 @@ class BaseInterceptorMethods {
} }
void handleMethodException(Throwable t) { void handleMethodException(Throwable t) {
if (ContextManager.activeSpan() != null) { if (ContextManager.isActive()) {
ContextManager.activeSpan().errorOccurred().log(t); ContextManager.activeSpan().errorOccurred().log(t);
} }
} }
......
...@@ -42,9 +42,8 @@ public class FilteringWebHandlerInterceptor implements InstanceMethodsAroundInte ...@@ -42,9 +42,8 @@ public class FilteringWebHandlerInterceptor implements InstanceMethodsAroundInte
ServerWebExchange exchange = (ServerWebExchange) allArguments[0]; ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
Route route = exchange.getRequiredAttribute(GATEWAY_ROUTE_ATTR); Route route = exchange.getRequiredAttribute(GATEWAY_ROUTE_ATTR);
AbstractSpan span = ContextManager.activeSpan(); if (ContextManager.isActive()) {
if (span != null) { ContextManager.activeSpan().tag("route", route.getId());
span.tag("route", route.getId());
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册