-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Why NettyRoutingFilterInterceptor not need to stop span?How to implement traceid not to duplicate #6842
Copy link
Copy link
Closed
Labels
questionEnd user question and discussion.End user question and discussion.
Milestone
Description
Please answer these questions before submitting your issue.
- Why do you submit this issue?
- Question or discussion
- Bug
- Requirement
- Feature or performance improvement
Question
- What do you want to know?
NettyRoutingFilterInterceptor code in apm-spring-cloud-gateway-2.1.x-plugin.
public class NettyRoutingFilterInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
EnhancedInstance enhancedInstance = getInstance(exchange);
AbstractSpan span = ContextManager.createLocalSpan("SpringCloudGateway/RoutingFilter");
if (enhancedInstance != null && enhancedInstance.getSkyWalkingDynamicField() != null) {
ContextManager.continued((ContextSnapshot) enhancedInstance.getSkyWalkingDynamicField());
}
span.setComponent(SPRING_CLOUD_GATEWAY);
}
public static EnhancedInstance getInstance(Object o) {
EnhancedInstance instance = null;
if (o instanceof DefaultServerWebExchange) {
instance = (EnhancedInstance) o;
} else if (o instanceof ServerWebExchangeDecorator) {
ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate();
return getInstance(delegate);
}
return instance;
}
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
return ret;
}
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Throwable t) {
ContextManager.activeSpan().log(t);
}
}
afterMethod function do nothing, how to clear trace context in CONTEXT ThreadLocal.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionEnd user question and discussion.End user question and discussion.