Loading apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixConcurrencyStrategyInterceptor.java +15 −2 Original line number Diff line number Diff line Loading @@ -35,7 +35,20 @@ public class HystrixConcurrencyStrategyInterceptor implements InstanceMethodsAro @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable { return new SWHystrixConcurrencyStrategyWrapper((HystrixConcurrencyStrategy)ret); SWHystrixPluginsWrapperCache wrapperCache = (SWHystrixPluginsWrapperCache) objInst.getSkyWalkingDynamicField(); if (wrapperCache == null || wrapperCache.getSwHystrixConcurrencyStrategyWrapper() == null) { synchronized (objInst) { if (wrapperCache == null) { wrapperCache = new SWHystrixPluginsWrapperCache(); objInst.setSkyWalkingDynamicField(wrapperCache); } if (wrapperCache.getSwHystrixConcurrencyStrategyWrapper() == null) { wrapperCache.setSwHystrixConcurrencyStrategyWrapper(new SWHystrixConcurrencyStrategyWrapper((HystrixConcurrencyStrategy) ret)); } } } return wrapperCache.getSwHystrixConcurrencyStrategyWrapper(); } @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Loading apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixPluginsInterceptor.java +14 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,20 @@ public class HystrixPluginsInterceptor implements InstanceMethodsAroundIntercept @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable { return new SWExecutionHookWrapper((HystrixCommandExecutionHook)ret); SWHystrixPluginsWrapperCache wrapperCache = (SWHystrixPluginsWrapperCache) objInst.getSkyWalkingDynamicField(); if (wrapperCache == null || wrapperCache.getSwExecutionHookWrapper() == null) { synchronized (objInst) { if (wrapperCache == null) { wrapperCache = new SWHystrixPluginsWrapperCache(); objInst.setSkyWalkingDynamicField(wrapperCache); } if (wrapperCache.getSwExecutionHookWrapper() == null) { wrapperCache.setSwExecutionHookWrapper(new SWExecutionHookWrapper((HystrixCommandExecutionHook) ret)); } } } return wrapperCache.getSwExecutionHookWrapper(); } @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Loading apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWHystrixConcurrencyStrategyWrapper.java +4 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,10 @@ public class SWHystrixConcurrencyStrategyWrapper extends HystrixConcurrencyStrat @Override public <T> Callable<T> wrapCallable(Callable<T> callable) { return new WrappedCallable<T>(ContextManager.getRuntimeContext().capture(), super.wrapCallable(callable)); Callable<T> delegateCallable = delegate != null ? delegate.wrapCallable(callable) : super.wrapCallable(callable); return new WrappedCallable<T>(ContextManager.getRuntimeContext().capture(), delegateCallable); } static class WrappedCallable<T> implements Callable<T> { Loading apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWHystrixPluginsWrapperCache.java 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.skywalking.apm.plugin.hystrix.v1; /** * {@link SWHystrixPluginsWrapperCache} record the {@link SWExecutionHookWrapper} and {@link SWHystrixConcurrencyStrategyWrapper} object for * storing in EnhancedInstance#dynamicField together. * * @author chenpengfei */ public class SWHystrixPluginsWrapperCache { private volatile SWExecutionHookWrapper swExecutionHookWrapper; private volatile SWHystrixConcurrencyStrategyWrapper swHystrixConcurrencyStrategyWrapper; public SWExecutionHookWrapper getSwExecutionHookWrapper() { return swExecutionHookWrapper; } public void setSwExecutionHookWrapper(SWExecutionHookWrapper swExecutionHookWrapper) { this.swExecutionHookWrapper = swExecutionHookWrapper; } public SWHystrixConcurrencyStrategyWrapper getSwHystrixConcurrencyStrategyWrapper() { return swHystrixConcurrencyStrategyWrapper; } public void setSwHystrixConcurrencyStrategyWrapper(SWHystrixConcurrencyStrategyWrapper swHystrixConcurrencyStrategyWrapper) { this.swHystrixConcurrencyStrategyWrapper = swHystrixConcurrencyStrategyWrapper; } } Loading
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixConcurrencyStrategyInterceptor.java +15 −2 Original line number Diff line number Diff line Loading @@ -35,7 +35,20 @@ public class HystrixConcurrencyStrategyInterceptor implements InstanceMethodsAro @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable { return new SWHystrixConcurrencyStrategyWrapper((HystrixConcurrencyStrategy)ret); SWHystrixPluginsWrapperCache wrapperCache = (SWHystrixPluginsWrapperCache) objInst.getSkyWalkingDynamicField(); if (wrapperCache == null || wrapperCache.getSwHystrixConcurrencyStrategyWrapper() == null) { synchronized (objInst) { if (wrapperCache == null) { wrapperCache = new SWHystrixPluginsWrapperCache(); objInst.setSkyWalkingDynamicField(wrapperCache); } if (wrapperCache.getSwHystrixConcurrencyStrategyWrapper() == null) { wrapperCache.setSwHystrixConcurrencyStrategyWrapper(new SWHystrixConcurrencyStrategyWrapper((HystrixConcurrencyStrategy) ret)); } } } return wrapperCache.getSwHystrixConcurrencyStrategyWrapper(); } @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Loading
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixPluginsInterceptor.java +14 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,20 @@ public class HystrixPluginsInterceptor implements InstanceMethodsAroundIntercept @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable { return new SWExecutionHookWrapper((HystrixCommandExecutionHook)ret); SWHystrixPluginsWrapperCache wrapperCache = (SWHystrixPluginsWrapperCache) objInst.getSkyWalkingDynamicField(); if (wrapperCache == null || wrapperCache.getSwExecutionHookWrapper() == null) { synchronized (objInst) { if (wrapperCache == null) { wrapperCache = new SWHystrixPluginsWrapperCache(); objInst.setSkyWalkingDynamicField(wrapperCache); } if (wrapperCache.getSwExecutionHookWrapper() == null) { wrapperCache.setSwExecutionHookWrapper(new SWExecutionHookWrapper((HystrixCommandExecutionHook) ret)); } } } return wrapperCache.getSwExecutionHookWrapper(); } @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Loading
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWHystrixConcurrencyStrategyWrapper.java +4 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,10 @@ public class SWHystrixConcurrencyStrategyWrapper extends HystrixConcurrencyStrat @Override public <T> Callable<T> wrapCallable(Callable<T> callable) { return new WrappedCallable<T>(ContextManager.getRuntimeContext().capture(), super.wrapCallable(callable)); Callable<T> delegateCallable = delegate != null ? delegate.wrapCallable(callable) : super.wrapCallable(callable); return new WrappedCallable<T>(ContextManager.getRuntimeContext().capture(), delegateCallable); } static class WrappedCallable<T> implements Callable<T> { Loading
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWHystrixPluginsWrapperCache.java 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.skywalking.apm.plugin.hystrix.v1; /** * {@link SWHystrixPluginsWrapperCache} record the {@link SWExecutionHookWrapper} and {@link SWHystrixConcurrencyStrategyWrapper} object for * storing in EnhancedInstance#dynamicField together. * * @author chenpengfei */ public class SWHystrixPluginsWrapperCache { private volatile SWExecutionHookWrapper swExecutionHookWrapper; private volatile SWHystrixConcurrencyStrategyWrapper swHystrixConcurrencyStrategyWrapper; public SWExecutionHookWrapper getSwExecutionHookWrapper() { return swExecutionHookWrapper; } public void setSwExecutionHookWrapper(SWExecutionHookWrapper swExecutionHookWrapper) { this.swExecutionHookWrapper = swExecutionHookWrapper; } public SWHystrixConcurrencyStrategyWrapper getSwHystrixConcurrencyStrategyWrapper() { return swHystrixConcurrencyStrategyWrapper; } public void setSwHystrixConcurrencyStrategyWrapper(SWHystrixConcurrencyStrategyWrapper swHystrixConcurrencyStrategyWrapper) { this.swHystrixConcurrencyStrategyWrapper = swHystrixConcurrencyStrategyWrapper; } }