diff --git a/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandGetFallbackInterceptor.java b/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandGetFallbackInterceptor.java index f935c77eb..2dd1f4f9c 100644 --- a/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandGetFallbackInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandGetFallbackInterceptor.java @@ -36,7 +36,9 @@ public class HystrixCommandGetFallbackInterceptor implements InstanceMethodsArou AbstractSpan activeSpan = ContextManager.createLocalSpan(enhanceRequireObjectCache.getOperationNamePrefix() + "/Fallback"); activeSpan.setComponent(ComponentsDefine.HYSTRIX); - ContextManager.continued(snapshot); + if (snapshot != null) { + ContextManager.continued(snapshot); + } } @Override diff --git a/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandRunInterceptor.java b/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandRunInterceptor.java index c6f1bcc97..28dce1a39 100644 --- a/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandRunInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandRunInterceptor.java @@ -41,7 +41,9 @@ public class HystrixCommandRunInterceptor implements InstanceMethodsAroundInterc AbstractSpan activeSpan = ContextManager.createLocalSpan(enhanceRequireObjectCache.getOperationNamePrefix() + "/Execution"); activeSpan.setComponent(ComponentsDefine.HYSTRIX); - ContextManager.continued(snapshot); + if (snapshot != null) { + ContextManager.continued(snapshot); + } // Because of `fall back` method running in other thread. so we need capture concurrent span for tracing. enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture()); diff --git a/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWExecutionHookWrapper.java b/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWExecutionHookWrapper.java index eedc646cd..fbe0022a0 100644 --- a/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWExecutionHookWrapper.java +++ b/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWExecutionHookWrapper.java @@ -41,7 +41,9 @@ public class SWExecutionHookWrapper extends HystrixCommandExecutionHook { public void onStart(HystrixInvokable commandInstance) { EnhancedInstance enhancedInstance = (EnhancedInstance)commandInstance; EnhanceRequireObjectCache enhanceRequireObjectCache = (EnhanceRequireObjectCache)enhancedInstance.getSkyWalkingDynamicField(); - enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture()); + if (ContextManager.isActive()) { + enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture()); + } actual.onStart(commandInstance); } @@ -166,7 +168,9 @@ public class SWExecutionHookWrapper extends HystrixCommandExecutionHook { @Override public void onStart(HystrixCommand commandInstance) { EnhancedInstance enhancedInstance = (EnhancedInstance)commandInstance; EnhanceRequireObjectCache enhanceRequireObjectCache = (EnhanceRequireObjectCache)enhancedInstance.getSkyWalkingDynamicField(); - enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture()); + if (ContextManager.isActive()) { + enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture()); + } actual.onStart(commandInstance); }