Avoided to interrupt the process of the application in the `SWExecutionHookWrapper` wrapper class. (#5803)
* Avoided to interrupt the process of the application in the `SWExecutionHookWrapper` wrapper class. * Polishing. Co-authored-by: 吴晟 Wu Sheng <wu.sheng@foxmail.com>
This commit is contained in:
parent
96014ddac2
commit
c3c56acf0c
|
|
@ -23,6 +23,8 @@ import com.netflix.hystrix.HystrixInvokable;
|
|||
import com.netflix.hystrix.exception.HystrixRuntimeException;
|
||||
import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook;
|
||||
import org.apache.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.apache.skywalking.apm.agent.core.logging.api.ILog;
|
||||
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
|
||||
/**
|
||||
|
|
@ -31,6 +33,8 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedI
|
|||
public class SWExecutionHookWrapper extends HystrixCommandExecutionHook {
|
||||
private final HystrixCommandExecutionHook actual;
|
||||
|
||||
private static ILog LOGGER = LogManager.getLogger(SWExecutionHookWrapper.class);
|
||||
|
||||
public SWExecutionHookWrapper(HystrixCommandExecutionHook actual) {
|
||||
this.actual = actual;
|
||||
}
|
||||
|
|
@ -42,10 +46,14 @@ public class SWExecutionHookWrapper extends HystrixCommandExecutionHook {
|
|||
return;
|
||||
}
|
||||
|
||||
EnhancedInstance enhancedInstance = (EnhancedInstance) commandInstance;
|
||||
EnhanceRequireObjectCache enhanceRequireObjectCache = (EnhanceRequireObjectCache) enhancedInstance.getSkyWalkingDynamicField();
|
||||
if (ContextManager.isActive()) {
|
||||
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
|
||||
try {
|
||||
EnhancedInstance enhancedInstance = (EnhancedInstance) commandInstance;
|
||||
EnhanceRequireObjectCache enhanceRequireObjectCache = (EnhanceRequireObjectCache) enhancedInstance.getSkyWalkingDynamicField();
|
||||
if (ContextManager.isActive()) {
|
||||
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to set ContextSnapshot.", e);
|
||||
}
|
||||
actual.onStart(commandInstance);
|
||||
}
|
||||
|
|
@ -194,10 +202,14 @@ public class SWExecutionHookWrapper extends HystrixCommandExecutionHook {
|
|||
return;
|
||||
}
|
||||
|
||||
EnhancedInstance enhancedInstance = (EnhancedInstance) commandInstance;
|
||||
EnhanceRequireObjectCache enhanceRequireObjectCache = (EnhanceRequireObjectCache) enhancedInstance.getSkyWalkingDynamicField();
|
||||
if (ContextManager.isActive()) {
|
||||
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
|
||||
try {
|
||||
EnhancedInstance enhancedInstance = (EnhancedInstance) commandInstance;
|
||||
EnhanceRequireObjectCache enhanceRequireObjectCache = (EnhanceRequireObjectCache) enhancedInstance.getSkyWalkingDynamicField();
|
||||
if (ContextManager.isActive()) {
|
||||
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to set ContextSnapshot.", e);
|
||||
}
|
||||
actual.onStart(commandInstance);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue