未验证 提交 c3c56acf 编写于 作者: Z zifeihan 提交者: GitHub

Avoided to interrupt the process of the application in the...

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's avatar吴晟 Wu Sheng <wu.sheng@foxmail.com>
上级 96014dda
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册