From f4b0c0c5a8f8746726f45e3fb879216c7a4c973c Mon Sep 17 00:00:00 2001 From: wang Date: Tue, 27 May 2025 09:35:55 +0800 Subject: [PATCH 01/11] fix parent class enhance issue --- .../enhance/ClassEnhancePluginDefine.java | 4 ++ .../v2/ClassEnhancePluginDefineV2.java | 4 ++ .../apm/agent/bytebuddy/biz/ChildBar.java | 27 ++++++++ .../apm/agent/bytebuddy/biz/ParentBar.java | 26 ++++++++ .../cases/AbstractInterceptTest.java | 25 +++++++- .../bytebuddy/cases/ReTransform4Test.java | 62 +++++++++++++++++++ 6 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ChildBar.java create mode 100644 apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ParentBar.java create mode 100644 apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/ReTransform4Test.java diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java index b595d89e92..5e8a3727d1 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java @@ -19,6 +19,7 @@ package org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance; import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.description.modifier.Visibility; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.dynamic.DynamicType; import net.bytebuddy.implementation.FieldAccessor; @@ -102,6 +103,9 @@ protected DynamicType.Builder enhanceInstance(TypeDescription typeDescription newClassBuilder = newClassBuilder.defineField( CONTEXT_ATTR_NAME, Object.class, ACC_PRIVATE | ACC_VOLATILE) .implement(EnhancedInstance.class) + .defineMethod("getSkyWalkingDynamicField", Object.class, Visibility.PUBLIC) + .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)) + .defineMethod("setSkyWalkingDynamicField", void.class, Visibility.PUBLIC).withParameters(Object.class) .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)); context.extendObjectCompleted(); } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/v2/ClassEnhancePluginDefineV2.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/v2/ClassEnhancePluginDefineV2.java index 8ea6cdfb99..11cd66b500 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/v2/ClassEnhancePluginDefineV2.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/v2/ClassEnhancePluginDefineV2.java @@ -18,6 +18,7 @@ package org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.v2; import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.description.modifier.Visibility; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.dynamic.DynamicType; import net.bytebuddy.implementation.FieldAccessor; @@ -135,6 +136,9 @@ protected DynamicType.Builder enhanceInstance(TypeDescription typeDescription newClassBuilder = newClassBuilder.defineField( CONTEXT_ATTR_NAME, Object.class, ACC_PRIVATE | ACC_VOLATILE) .implement(EnhancedInstance.class) + .defineMethod("getSkyWalkingDynamicField", Object.class, Visibility.PUBLIC) + .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)) + .defineMethod("setSkyWalkingDynamicField", void.class, Visibility.PUBLIC).withParameters(Object.class) .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)); context.extendObjectCompleted(); } diff --git a/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ChildBar.java b/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ChildBar.java new file mode 100644 index 0000000000..e7ac8d49ff --- /dev/null +++ b/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ChildBar.java @@ -0,0 +1,27 @@ +/* + * 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.agent.bytebuddy.biz; + +public class ChildBar extends ParentBar { + + public String sayHelloChild() { + return "Joe"; + } + +} diff --git a/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ParentBar.java b/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ParentBar.java new file mode 100644 index 0000000000..6113b4c41a --- /dev/null +++ b/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/biz/ParentBar.java @@ -0,0 +1,26 @@ +/* + * 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.agent.bytebuddy.biz; + +public class ParentBar { + + public String sayHelloParent() { + return "Joe"; + } +} diff --git a/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/AbstractInterceptTest.java b/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/AbstractInterceptTest.java index ba9cf4d372..05919ae0b4 100644 --- a/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/AbstractInterceptTest.java +++ b/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/AbstractInterceptTest.java @@ -24,6 +24,7 @@ import net.bytebuddy.agent.builder.SWAgentBuilderDefault; import net.bytebuddy.agent.builder.SWDescriptionStrategy; import net.bytebuddy.agent.builder.SWNativeMethodStrategy; +import net.bytebuddy.description.modifier.Visibility; import net.bytebuddy.implementation.FieldAccessor; import net.bytebuddy.implementation.MethodDelegation; import net.bytebuddy.implementation.SWImplementationContextFactory; @@ -38,6 +39,7 @@ import org.apache.skywalking.apm.agent.bytebuddy.SWAuxiliaryTypeNamingStrategy; import org.apache.skywalking.apm.agent.bytebuddy.SWClassFileLocator; import org.apache.skywalking.apm.agent.bytebuddy.biz.BizFoo; +import org.apache.skywalking.apm.agent.bytebuddy.biz.ChildBar; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; import org.junit.Assert; import org.junit.BeforeClass; @@ -63,6 +65,8 @@ public class AbstractInterceptTest { public static final String BIZ_FOO_CLASS_NAME = "org.apache.skywalking.apm.agent.bytebuddy.biz.BizFoo"; public static final String PROJECT_SERVICE_CLASS_NAME = "org.apache.skywalking.apm.agent.bytebuddy.biz.ProjectService"; public static final String DOC_SERVICE_CLASS_NAME = "org.apache.skywalking.apm.agent.bytebuddy.biz.DocService"; + public static final String PARENT_BAR_CLASS_NAME = "org.apache.skywalking.apm.agent.bytebuddy.biz.ParentBar"; + public static final String CHILD_BAR_CLASS_NAME = "org.apache.skywalking.apm.agent.bytebuddy.biz.ChildBar"; public static final String SAY_HELLO_METHOD = "sayHello"; public static final int BASE_INT_VALUE = 100; public static final String CONSTRUCTOR_INTERCEPTOR_CLASS = "constructorInterceptorClass"; @@ -85,6 +89,20 @@ protected void failed(Throwable e, Description description) { } }; + protected static void callBar(int round) { + Log.info("-------------"); + Log.info("callChildBar: " + round); + // load target class + String strResultChild = new ChildBar().sayHelloChild(); + Log.info("result: " + strResultChild); + + String strResultParent = new ChildBar().sayHelloParent(); + Log.info("result: " + strResultParent); + + Assert.assertEquals("String value is unexpected", "John", strResultChild); + Assert.assertEquals("String value is unexpected", "John", strResultParent); + } + protected static void callBizFoo(int round) { Log.info("-------------"); Log.info("callBizFoo: " + round); @@ -115,7 +133,7 @@ protected static void checkConstructorInterceptor(String className, int round) { protected static void checkInterface(Class testClass, Class interfaceCls) { Assert.assertTrue("Check interface failure, the test class: " + testClass + " does not implement the expected interface: " + interfaceCls, - EnhancedInstance.class.isAssignableFrom(BizFoo.class)); + EnhancedInstance.class.isAssignableFrom(testClass)); } protected static void checkErrors() { @@ -195,6 +213,9 @@ protected void installInterface(String className) { builder = builder.defineField( CONTEXT_ATTR_NAME, Object.class, ACC_PRIVATE | ACC_VOLATILE) .implement(EnhancedInstance.class) + .defineMethod("getSkyWalkingDynamicField", Object.class, Visibility.PUBLIC) + .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)) + .defineMethod("setSkyWalkingDynamicField", void.class, Visibility.PUBLIC).withParameters(Object.class) .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)); } return builder; @@ -223,7 +244,7 @@ protected void installTraceClassTransformer(String msg) { ClassFileTransformer classFileTransformer = new ClassFileTransformer() { @Override public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { - if (className.endsWith("BizFoo") || className.endsWith("ProjectService") || className.endsWith("DocService")) { + if (className.endsWith("BizFoo") || className.endsWith("ProjectService") || className.endsWith("DocService") || className.endsWith("ChildBar") || className.endsWith("ParentBar")) { Log.error(msg + className); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ClassReader cr = new ClassReader(classfileBuffer); diff --git a/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/ReTransform4Test.java b/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/ReTransform4Test.java new file mode 100644 index 0000000000..877dd416e7 --- /dev/null +++ b/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/ReTransform4Test.java @@ -0,0 +1,62 @@ +/* + * 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.agent.bytebuddy.cases; + +import net.bytebuddy.agent.ByteBuddyAgent; +import org.apache.skywalking.apm.agent.bytebuddy.biz.ChildBar; +import org.apache.skywalking.apm.agent.bytebuddy.biz.ParentBar; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.junit.Test; + +import java.lang.instrument.Instrumentation; + +public class ReTransform4Test extends AbstractReTransformTest { + + @Test + public void testInterceptConstructor() throws Exception { + Instrumentation instrumentation = ByteBuddyAgent.install(); + + // install transformer + installMethodInterceptor(PARENT_BAR_CLASS_NAME, "sayHelloParent", 1); + installMethodInterceptor(CHILD_BAR_CLASS_NAME, "sayHelloChild", 1); + // implement EnhancedInstance + installInterface(PARENT_BAR_CLASS_NAME); + installInterface(CHILD_BAR_CLASS_NAME); + + // call target class + callBar(1); + + // check interceptors + checkInterface(ParentBar.class, EnhancedInstance.class); + checkInterface(ChildBar.class, EnhancedInstance.class); + checkErrors(); + + installTraceClassTransformer("Trace class: "); + + // do retransform + reTransform(instrumentation, ChildBar.class); + + // check interceptors + checkInterface(ParentBar.class, EnhancedInstance.class); + checkInterface(ChildBar.class, EnhancedInstance.class); + checkErrors(); + } + +} + From 61343ce9385c45645a2bc2c22bef354c75d2fc61 Mon Sep 17 00:00:00 2001 From: wang Date: Tue, 27 May 2025 14:15:24 +0800 Subject: [PATCH 02/11] update CHANGES log --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 8affde9592..8e58c3459d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Release Notes. * Agent kernel services could be not-booted-yet as ServiceManager#INSTANCE#boot executed after agent transfer initialization. Delay so11y metrics#build when the services are not ready to avoid MeterService status is not initialized. +* Fix retransform failure when enhancing both parent and child classes. All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/236?closed=1) From a7d419a86cf708695fd4171c0f62770ad01ae5a6 Mon Sep 17 00:00:00 2001 From: wang Date: Wed, 28 May 2025 09:39:49 +0800 Subject: [PATCH 03/11] set the getter/setter method name as a constant --- .../core/plugin/AbstractClassEnhancePluginDefine.java | 8 ++++++++ .../interceptor/enhance/ClassEnhancePluginDefine.java | 4 ++-- .../enhance/v2/ClassEnhancePluginDefineV2.java | 4 ++-- .../apm/agent/bytebuddy/cases/AbstractInterceptTest.java | 6 ++++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java index c53e54f0fa..f0ab14a75b 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java @@ -51,6 +51,14 @@ public abstract class AbstractClassEnhancePluginDefine { * New field name. */ public static final String CONTEXT_ATTR_NAME = "_$EnhancedClassField_ws"; + /** + * Getter method name. + */ + public static final String CONTEXT_GETTER_NAME = "getSkyWalkingDynamicField"; + /** + * Setter method name. + */ + public static final String CONTEXT_SETTER_NAME = "setSkyWalkingDynamicField"; /** * Main entrance of enhancing the class. diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java index 5e8a3727d1..ec6628fe95 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java @@ -103,9 +103,9 @@ protected DynamicType.Builder enhanceInstance(TypeDescription typeDescription newClassBuilder = newClassBuilder.defineField( CONTEXT_ATTR_NAME, Object.class, ACC_PRIVATE | ACC_VOLATILE) .implement(EnhancedInstance.class) - .defineMethod("getSkyWalkingDynamicField", Object.class, Visibility.PUBLIC) + .defineMethod(CONTEXT_GETTER_NAME, Object.class, Visibility.PUBLIC) .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)) - .defineMethod("setSkyWalkingDynamicField", void.class, Visibility.PUBLIC).withParameters(Object.class) + .defineMethod(CONTEXT_SETTER_NAME, void.class, Visibility.PUBLIC).withParameters(Object.class) .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)); context.extendObjectCompleted(); } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/v2/ClassEnhancePluginDefineV2.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/v2/ClassEnhancePluginDefineV2.java index 11cd66b500..3423ac1392 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/v2/ClassEnhancePluginDefineV2.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/v2/ClassEnhancePluginDefineV2.java @@ -136,9 +136,9 @@ protected DynamicType.Builder enhanceInstance(TypeDescription typeDescription newClassBuilder = newClassBuilder.defineField( CONTEXT_ATTR_NAME, Object.class, ACC_PRIVATE | ACC_VOLATILE) .implement(EnhancedInstance.class) - .defineMethod("getSkyWalkingDynamicField", Object.class, Visibility.PUBLIC) + .defineMethod(CONTEXT_GETTER_NAME, Object.class, Visibility.PUBLIC) .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)) - .defineMethod("setSkyWalkingDynamicField", void.class, Visibility.PUBLIC).withParameters(Object.class) + .defineMethod(CONTEXT_SETTER_NAME, void.class, Visibility.PUBLIC).withParameters(Object.class) .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)); context.extendObjectCompleted(); } diff --git a/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/AbstractInterceptTest.java b/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/AbstractInterceptTest.java index 05919ae0b4..627fc8888d 100644 --- a/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/AbstractInterceptTest.java +++ b/apm-sniffer/bytebuddy-patch/src/test/java/org/apache/skywalking/apm/agent/bytebuddy/cases/AbstractInterceptTest.java @@ -60,6 +60,8 @@ import static net.bytebuddy.jar.asm.Opcodes.ACC_PRIVATE; import static net.bytebuddy.jar.asm.Opcodes.ACC_VOLATILE; import static org.apache.skywalking.apm.agent.core.plugin.AbstractClassEnhancePluginDefine.CONTEXT_ATTR_NAME; +import static org.apache.skywalking.apm.agent.core.plugin.AbstractClassEnhancePluginDefine.CONTEXT_GETTER_NAME; +import static org.apache.skywalking.apm.agent.core.plugin.AbstractClassEnhancePluginDefine.CONTEXT_SETTER_NAME; public class AbstractInterceptTest { public static final String BIZ_FOO_CLASS_NAME = "org.apache.skywalking.apm.agent.bytebuddy.biz.BizFoo"; @@ -213,9 +215,9 @@ protected void installInterface(String className) { builder = builder.defineField( CONTEXT_ATTR_NAME, Object.class, ACC_PRIVATE | ACC_VOLATILE) .implement(EnhancedInstance.class) - .defineMethod("getSkyWalkingDynamicField", Object.class, Visibility.PUBLIC) + .defineMethod(CONTEXT_GETTER_NAME, Object.class, Visibility.PUBLIC) .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)) - .defineMethod("setSkyWalkingDynamicField", void.class, Visibility.PUBLIC).withParameters(Object.class) + .defineMethod(CONTEXT_SETTER_NAME, void.class, Visibility.PUBLIC).withParameters(Object.class) .intercept(FieldAccessor.ofField(CONTEXT_ATTR_NAME)); } return builder; From 507b366df143e7d597df42cdef30c257cd8a564d Mon Sep 17 00:00:00 2001 From: wang Date: Wed, 9 Jul 2025 18:12:54 +0800 Subject: [PATCH 04/11] fix spring aop proxy change --- .github/workflows/plugins-test.2.yaml | 1 + .../patch/AutoProxyCreatorInterceptor.java | 53 +++++++++ .../ProxyProcessorSupportInterceptor.java | 52 +++++++++ .../AutoProxyCreatorInstrumentation.java | 78 +++++++++++++ .../ProxyProcessorSupportInstrumentation.java | 69 +++++++++++ .../src/main/resources/skywalking-plugin.def | 2 + .../spring-retry-scenario/bin/startup.sh | 21 ++++ .../config/expectedData.yaml | 48 ++++++++ .../spring-retry-scenario/configuration.yml | 20 ++++ .../scenarios/spring-retry-scenario/pom.xml | 107 ++++++++++++++++++ .../src/main/assembly/assembly.xml | 41 +++++++ .../testcase/spring/retry/Application.java | 41 +++++++ .../retry/controller/CaseController.java | 23 ++++ .../spring/retry/service/CaseService.java | 17 +++ .../src/main/resources/application.properties | 19 ++++ .../src/main/resources/log4j2.xml | 30 +++++ .../support-version.list | 18 +++ 17 files changed, 640 insertions(+) create mode 100644 apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutoProxyCreatorInterceptor.java create mode 100644 apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/ProxyProcessorSupportInterceptor.java create mode 100644 apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/define/AutoProxyCreatorInstrumentation.java create mode 100644 apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/define/ProxyProcessorSupportInstrumentation.java create mode 100644 test/plugin/scenarios/spring-retry-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/spring-retry-scenario/configuration.yml create mode 100644 test/plugin/scenarios/spring-retry-scenario/pom.xml create mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/Application.java create mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java create mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java create mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/resources/application.properties create mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/spring-retry-scenario/support-version.list diff --git a/.github/workflows/plugins-test.2.yaml b/.github/workflows/plugins-test.2.yaml index ccb6a7865d..fd30d793c7 100644 --- a/.github/workflows/plugins-test.2.yaml +++ b/.github/workflows/plugins-test.2.yaml @@ -72,6 +72,7 @@ jobs: - spring-cloud-feign-1.2.x-scenario - spring-cloud-feign-2.x-scenario - spring-tx-scenario + - spring-retry-scenario - struts2.3-scenario - struts2.5-scenario - cxf-scenario diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutoProxyCreatorInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutoProxyCreatorInterceptor.java new file mode 100644 index 0000000000..98326f9b38 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutoProxyCreatorInterceptor.java @@ -0,0 +1,53 @@ +/* + * 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.spring.patch; + +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; + +import java.lang.reflect.Method; + +/** + * AutoProxyCreatorInterceptor check that the bean has been implement {@link EnhancedInstance}. + * if yes, true will be returned. + */ +public class AutoProxyCreatorInterceptor implements InstanceMethodsAroundInterceptor { + + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + + Class ifc = (Class) allArguments[0]; + return ((boolean) ret) || ifc.getName().equals("org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance"); + } + + @Override + public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + + } + +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/ProxyProcessorSupportInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/ProxyProcessorSupportInterceptor.java new file mode 100644 index 0000000000..75ced4a0bd --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/ProxyProcessorSupportInterceptor.java @@ -0,0 +1,52 @@ +/* + * 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.spring.patch; + +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; + +import java.lang.reflect.Method; + +/** + * ProxyProcessorSupportInterceptor check that the bean has been implement {@link EnhancedInstance}. + * if yes, true will be returned. + */ +public class ProxyProcessorSupportInterceptor implements InstanceMethodsAroundInterceptor { + + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + Class ifc = (Class) allArguments[0]; + return ((boolean) ret) || ifc.getName().equals("org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance"); + } + + @Override + public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + + } + +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/define/AutoProxyCreatorInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/define/AutoProxyCreatorInstrumentation.java new file mode 100644 index 0000000000..26e6147e69 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/define/AutoProxyCreatorInstrumentation.java @@ -0,0 +1,78 @@ +/* + * 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.spring.patch.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import java.util.Collections; +import java.util.List; + +import static net.bytebuddy.matcher.ElementMatchers.named; + +public class AutoProxyCreatorInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator"; + public static final String ENHANCE_METHOD = "isConfigurationCallbackInterface"; + public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.spring.patch.AutoProxyCreatorInterceptor"; + + @Override + public final ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public final InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named(ENHANCE_METHOD); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPT_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override + protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } + + @Override + protected List witnessMethods() { + return Collections.singletonList(new WitnessMethod(ENHANCE_CLASS, named(ENHANCE_METHOD))); + } + +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/define/ProxyProcessorSupportInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/define/ProxyProcessorSupportInstrumentation.java new file mode 100644 index 0000000000..78de2969c2 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/define/ProxyProcessorSupportInstrumentation.java @@ -0,0 +1,69 @@ +/* + * 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.spring.patch.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; + +public class ProxyProcessorSupportInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "org.springframework.aop.framework.ProxyProcessorSupport"; + public static final String ENHANCE_METHOD = "isInternalLanguageInterface"; + public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.spring.patch.ProxyProcessorSupportInterceptor"; + + @Override + public final ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public final InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named(ENHANCE_METHOD); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPT_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override + protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } + +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/resources/skywalking-plugin.def index e51178b97b..3a21d2b4aa 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/resources/skywalking-plugin.def +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/resources/skywalking-plugin.def @@ -19,3 +19,5 @@ spring-core-patch=org.apache.skywalking.apm.plugin.spring.patch.define.Autowired spring-core-patch=org.apache.skywalking.apm.plugin.spring.patch.define.AopExpressionMatchInstrumentation spring-core-patch=org.apache.skywalking.apm.plugin.spring.patch.define.AspectJExpressionPointCutInstrumentation spring-core-patch=org.apache.skywalking.apm.plugin.spring.patch.define.BeanWrapperImplInstrumentation +spring-core-patch=org.apache.skywalking.apm.plugin.spring.patch.define.ProxyProcessorSupportInstrumentation +spring-core-patch=org.apache.skywalking.apm.plugin.spring.patch.define.AutoProxyCreatorInstrumentation diff --git a/test/plugin/scenarios/spring-retry-scenario/bin/startup.sh b/test/plugin/scenarios/spring-retry-scenario/bin/startup.sh new file mode 100644 index 0000000000..f7f42e3677 --- /dev/null +++ b/test/plugin/scenarios/spring-retry-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# 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. + +home="$(cd "$(dirname $0)"; pwd)" + +java -jar ${agent_opts} ${home}/../libs/spring-retry-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..bb303fdf42 --- /dev/null +++ b/test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml @@ -0,0 +1,48 @@ +# 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. +segmentItems: + - serviceName: spring-retry-scenario + segmentSize: nq 0 + segments: + - segmentId: not null + spans: + - operationName: test.org.apache.skywalking.apm.testcase.spring.retry.service.CaseService.handle() + parentSpanId: 0 + spanId: 1 + spanLayer: Unknown + startTime: not null + endTime: not null + componentId: not null + isError: false + spanType: Local + peer: '' + skipAnalysis: false + - operationName: HEAD:/case/healthCheck + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: not null + endTime: not null + componentId: not null + isError: false + spanType: Entry + peer: '' + skipAnalysis: false + tags: + - {key: url, value: 'http://localhost:8080/spring-retry-scenario/case/healthCheck'} + - {key: http.method, value: HEAD} + - {key: http.status_code, value: '200'} + diff --git a/test/plugin/scenarios/spring-retry-scenario/configuration.yml b/test/plugin/scenarios/spring-retry-scenario/configuration.yml new file mode 100644 index 0000000000..571264cff2 --- /dev/null +++ b/test/plugin/scenarios/spring-retry-scenario/configuration.yml @@ -0,0 +1,20 @@ +# 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. + +type: jvm +entryService: http://localhost:8080/spring-retry-scenario/case/healthCheck +healthCheck: http://localhost:8080/spring-retry-scenario/case/healthCheck +startScript: ./bin/startup.sh diff --git a/test/plugin/scenarios/spring-retry-scenario/pom.xml b/test/plugin/scenarios/spring-retry-scenario/pom.xml new file mode 100644 index 0000000000..31f339277e --- /dev/null +++ b/test/plugin/scenarios/spring-retry-scenario/pom.xml @@ -0,0 +1,107 @@ + + + + 4.0.0 + + org.apache.skywalking + spring-retry-scenario + 5.0.0 + + + UTF-8 + 1.8 + 3.8.1 + 1.4.1.RELEASE + ${test.framework.version} + 9.4.0 + + + skywalking-spring-retry-scenario + + + + org.springframework.boot + spring-boot-starter-web + ${spring.boot.version} + + + org.springframework.boot + spring-boot-starter-aop + ${spring.boot.version} + + + org.springframework.retry + spring-retry + 1.2.5.RELEASE + + + org.apache.skywalking + apm-toolkit-trace + ${apm-toolkit-trace.version} + + + + + spring-retry-scenario + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/spring-retry-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..eab9576b2b --- /dev/null +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/spring-retry-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/Application.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/Application.java new file mode 100644 index 0000000000..7cbdac4ba5 --- /dev/null +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/Application.java @@ -0,0 +1,41 @@ +/* + * 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 test.org.apache.skywalking.apm.testcase.spring.retry; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.retry.annotation.EnableRetry; + +@EnableAutoConfiguration +@Configuration +@ComponentScan +@EnableRetry +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } + +} diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java new file mode 100644 index 0000000000..da59f20773 --- /dev/null +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java @@ -0,0 +1,23 @@ +package test.org.apache.skywalking.apm.testcase.spring.retry.controller; + +import org.springframework.web.bind.annotation.ResponseBody; +import test.org.apache.skywalking.apm.testcase.spring.retry.service.CaseService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@ResponseBody +@RequestMapping("/case") +public class CaseController { + + @Autowired + private CaseService caseService; + + @RequestMapping("/healthCheck") + public String health() { + caseService.handle(); + return "success"; + } + +} diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java new file mode 100644 index 0000000000..1ef9089416 --- /dev/null +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java @@ -0,0 +1,17 @@ +package test.org.apache.skywalking.apm.testcase.spring.retry.service; + +import org.apache.skywalking.apm.toolkit.trace.Trace; +import org.springframework.retry.annotation.Backoff; +import org.springframework.retry.annotation.Retryable; +import org.springframework.stereotype.Service; + +@Service +public class CaseService { + + @Retryable(value = Exception.class, backoff = @Backoff(delay = 1000, multiplier = 2)) + @Trace + public void handle() { + System.out.println("handle"); + } + +} diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/resources/application.properties b/test/plugin/scenarios/spring-retry-scenario/src/main/resources/application.properties new file mode 100644 index 0000000000..bb0c9afd00 --- /dev/null +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/resources/application.properties @@ -0,0 +1,19 @@ +# +# 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. +# +# +server.port=8080 +server.contextPath=/spring-retry-scenario diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/spring-retry-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..9849ed5a8a --- /dev/null +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/spring-retry-scenario/support-version.list b/test/plugin/scenarios/spring-retry-scenario/support-version.list new file mode 100644 index 0000000000..97b610dc4a --- /dev/null +++ b/test/plugin/scenarios/spring-retry-scenario/support-version.list @@ -0,0 +1,18 @@ +# 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. + +1.4.1.RELEASE +1.5.16.RELEASE \ No newline at end of file From 0735c039bbcaee878edf0f6a7d01229c0570bfd5 Mon Sep 17 00:00:00 2001 From: wang Date: Thu, 10 Jul 2025 09:57:27 +0800 Subject: [PATCH 05/11] add license header --- .../retry/controller/CaseController.java | 18 ++++++++++++++++++ .../spring/retry/service/CaseService.java | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java index da59f20773..fd7e4d0315 100644 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java @@ -1,3 +1,21 @@ +/* + * 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 test.org.apache.skywalking.apm.testcase.spring.retry.controller; import org.springframework.web.bind.annotation.ResponseBody; diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java index 1ef9089416..738c5787db 100644 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java @@ -1,3 +1,21 @@ +/* + * 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 test.org.apache.skywalking.apm.testcase.spring.retry.service; import org.apache.skywalking.apm.toolkit.trace.Trace; From 40ab21bf79ee605c0eb9822f15400c3b4e99b960 Mon Sep 17 00:00:00 2001 From: wang Date: Thu, 10 Jul 2025 10:14:51 +0800 Subject: [PATCH 06/11] rename package name --- .../skywalking/apm/testcase/spring/retry/Application.java | 2 +- .../apm/testcase/spring/retry/controller/CaseController.java | 4 ++-- .../apm/testcase/spring/retry/service/CaseService.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename test/plugin/scenarios/spring-retry-scenario/src/main/java/test/{org => }/apache/skywalking/apm/testcase/spring/retry/Application.java (95%) rename test/plugin/scenarios/spring-retry-scenario/src/main/java/test/{org => }/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java (89%) rename test/plugin/scenarios/spring-retry-scenario/src/main/java/test/{org => }/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java (94%) diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/Application.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/Application.java similarity index 95% rename from test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/Application.java rename to test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/Application.java index 7cbdac4ba5..c9ba3b70cb 100644 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/Application.java +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/Application.java @@ -16,7 +16,7 @@ * */ -package test.org.apache.skywalking.apm.testcase.spring.retry; +package test.apache.skywalking.apm.testcase.spring.retry; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java similarity index 89% rename from test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java rename to test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java index fd7e4d0315..e3a94e5c9d 100644 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java @@ -16,10 +16,10 @@ * */ -package test.org.apache.skywalking.apm.testcase.spring.retry.controller; +package test.apache.skywalking.apm.testcase.spring.retry.controller; import org.springframework.web.bind.annotation.ResponseBody; -import test.org.apache.skywalking.apm.testcase.spring.retry.service.CaseService; +import test.apache.skywalking.apm.testcase.spring.retry.service.CaseService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java similarity index 94% rename from test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java rename to test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java index 738c5787db..aeedc612ff 100644 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/org/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java @@ -16,7 +16,7 @@ * */ -package test.org.apache.skywalking.apm.testcase.spring.retry.service; +package test.apache.skywalking.apm.testcase.spring.retry.service; import org.apache.skywalking.apm.toolkit.trace.Trace; import org.springframework.retry.annotation.Backoff; From b1f17684bc0c579d4d8c32f3a15d50f12499bfcc Mon Sep 17 00:00:00 2001 From: wang Date: Thu, 10 Jul 2025 12:05:52 +0800 Subject: [PATCH 07/11] remove system print --- .../apm/testcase/spring/retry/service/CaseService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java index aeedc612ff..e7421cf299 100644 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java +++ b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java @@ -29,7 +29,6 @@ public class CaseService { @Retryable(value = Exception.class, backoff = @Backoff(delay = 1000, multiplier = 2)) @Trace public void handle() { - System.out.println("handle"); } } From 8e54734ac7430dc4e50584641dcc6cca42e53b50 Mon Sep 17 00:00:00 2001 From: wang Date: Thu, 10 Jul 2025 14:24:13 +0800 Subject: [PATCH 08/11] update operationName in expectedData.yaml --- .../scenarios/spring-retry-scenario/config/expectedData.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml index bb303fdf42..a7b79e5641 100644 --- a/test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml @@ -19,7 +19,7 @@ segmentItems: segments: - segmentId: not null spans: - - operationName: test.org.apache.skywalking.apm.testcase.spring.retry.service.CaseService.handle() + - operationName: test.apache.skywalking.apm.testcase.spring.retry.service.CaseService.handle() parentSpanId: 0 spanId: 1 spanLayer: Unknown From 6253528600c4694c344fd7389e0e17be7ab4cc63 Mon Sep 17 00:00:00 2001 From: wang Date: Mon, 28 Jul 2025 19:58:36 +0800 Subject: [PATCH 09/11] update test scenario --- .github/workflows/plugins-test.2.yaml | 1 - .../scenarios/spring-4.1.x-scenario/pom.xml | 21 ++++ .../testcase/spring3/config/RetryConfig.java | 9 ++ .../spring3/service/TestServiceBean.java | 9 ++ .../spring-retry-scenario/bin/startup.sh | 21 ---- .../config/expectedData.yaml | 48 -------- .../spring-retry-scenario/configuration.yml | 20 ---- .../scenarios/spring-retry-scenario/pom.xml | 107 ------------------ .../src/main/assembly/assembly.xml | 41 ------- .../testcase/spring/retry/Application.java | 41 ------- .../retry/controller/CaseController.java | 41 ------- .../spring/retry/service/CaseService.java | 34 ------ .../src/main/resources/application.properties | 19 ---- .../src/main/resources/log4j2.xml | 30 ----- .../support-version.list | 18 --- 15 files changed, 39 insertions(+), 421 deletions(-) create mode 100644 test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/config/RetryConfig.java delete mode 100644 test/plugin/scenarios/spring-retry-scenario/bin/startup.sh delete mode 100644 test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml delete mode 100644 test/plugin/scenarios/spring-retry-scenario/configuration.yml delete mode 100644 test/plugin/scenarios/spring-retry-scenario/pom.xml delete mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/assembly/assembly.xml delete mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/Application.java delete mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java delete mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java delete mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/resources/application.properties delete mode 100644 test/plugin/scenarios/spring-retry-scenario/src/main/resources/log4j2.xml delete mode 100644 test/plugin/scenarios/spring-retry-scenario/support-version.list diff --git a/.github/workflows/plugins-test.2.yaml b/.github/workflows/plugins-test.2.yaml index fd30d793c7..ccb6a7865d 100644 --- a/.github/workflows/plugins-test.2.yaml +++ b/.github/workflows/plugins-test.2.yaml @@ -72,7 +72,6 @@ jobs: - spring-cloud-feign-1.2.x-scenario - spring-cloud-feign-2.x-scenario - spring-tx-scenario - - spring-retry-scenario - struts2.3-scenario - struts2.5-scenario - cxf-scenario diff --git a/test/plugin/scenarios/spring-4.1.x-scenario/pom.xml b/test/plugin/scenarios/spring-4.1.x-scenario/pom.xml index 012ab866eb..b6a8d68bb0 100644 --- a/test/plugin/scenarios/spring-4.1.x-scenario/pom.xml +++ b/test/plugin/scenarios/spring-4.1.x-scenario/pom.xml @@ -33,6 +33,7 @@ 3.8.1 4.1.0.RELEASE spring + 9.4.0 skywalking-spring-4.1.x-scenario @@ -86,6 +87,26 @@ log4j-core 2.8.1 + + org.springframework + spring-aop + ${test.framework.version} + + + org.springframework + spring-aspects + ${test.framework.version} + + + org.springframework.retry + spring-retry + 1.2.5.RELEASE + + + org.apache.skywalking + apm-toolkit-trace + ${apm-toolkit-trace.version} + diff --git a/test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/config/RetryConfig.java b/test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/config/RetryConfig.java new file mode 100644 index 0000000000..2e8de3308b --- /dev/null +++ b/test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/config/RetryConfig.java @@ -0,0 +1,9 @@ +package test.apache.skywalking.apm.testcase.spring3.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.retry.annotation.EnableRetry; + +@Configuration +@EnableRetry +public class RetryConfig { +} diff --git a/test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/service/TestServiceBean.java b/test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/service/TestServiceBean.java index c940d5425c..b99b6b38c3 100644 --- a/test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/service/TestServiceBean.java +++ b/test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/service/TestServiceBean.java @@ -18,7 +18,10 @@ package test.apache.skywalking.apm.testcase.spring3.service; +import org.apache.skywalking.apm.toolkit.trace.Trace; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.retry.annotation.Backoff; +import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Service; import test.apache.skywalking.apm.testcase.spring3.component.TestComponentBean; import test.apache.skywalking.apm.testcase.spring3.dao.TestRepositoryBean; @@ -35,4 +38,10 @@ public void doSomeBusiness(String name) { componentBean.componentMethod(name); repositoryBean.doSomeStuff(name); } + + // Test the class is enhanced by both SkyWalking and Spring AOP + @Retryable(value = Exception.class, backoff = @Backoff(delay = 1000, multiplier = 2)) + @Trace + private void doRetry() { + } } diff --git a/test/plugin/scenarios/spring-retry-scenario/bin/startup.sh b/test/plugin/scenarios/spring-retry-scenario/bin/startup.sh deleted file mode 100644 index f7f42e3677..0000000000 --- a/test/plugin/scenarios/spring-retry-scenario/bin/startup.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# 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. - -home="$(cd "$(dirname $0)"; pwd)" - -java -jar ${agent_opts} ${home}/../libs/spring-retry-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml deleted file mode 100644 index a7b79e5641..0000000000 --- a/test/plugin/scenarios/spring-retry-scenario/config/expectedData.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# 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. -segmentItems: - - serviceName: spring-retry-scenario - segmentSize: nq 0 - segments: - - segmentId: not null - spans: - - operationName: test.apache.skywalking.apm.testcase.spring.retry.service.CaseService.handle() - parentSpanId: 0 - spanId: 1 - spanLayer: Unknown - startTime: not null - endTime: not null - componentId: not null - isError: false - spanType: Local - peer: '' - skipAnalysis: false - - operationName: HEAD:/case/healthCheck - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: not null - endTime: not null - componentId: not null - isError: false - spanType: Entry - peer: '' - skipAnalysis: false - tags: - - {key: url, value: 'http://localhost:8080/spring-retry-scenario/case/healthCheck'} - - {key: http.method, value: HEAD} - - {key: http.status_code, value: '200'} - diff --git a/test/plugin/scenarios/spring-retry-scenario/configuration.yml b/test/plugin/scenarios/spring-retry-scenario/configuration.yml deleted file mode 100644 index 571264cff2..0000000000 --- a/test/plugin/scenarios/spring-retry-scenario/configuration.yml +++ /dev/null @@ -1,20 +0,0 @@ -# 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. - -type: jvm -entryService: http://localhost:8080/spring-retry-scenario/case/healthCheck -healthCheck: http://localhost:8080/spring-retry-scenario/case/healthCheck -startScript: ./bin/startup.sh diff --git a/test/plugin/scenarios/spring-retry-scenario/pom.xml b/test/plugin/scenarios/spring-retry-scenario/pom.xml deleted file mode 100644 index 31f339277e..0000000000 --- a/test/plugin/scenarios/spring-retry-scenario/pom.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - 4.0.0 - - org.apache.skywalking - spring-retry-scenario - 5.0.0 - - - UTF-8 - 1.8 - 3.8.1 - 1.4.1.RELEASE - ${test.framework.version} - 9.4.0 - - - skywalking-spring-retry-scenario - - - - org.springframework.boot - spring-boot-starter-web - ${spring.boot.version} - - - org.springframework.boot - spring-boot-starter-aop - ${spring.boot.version} - - - org.springframework.retry - spring-retry - 1.2.5.RELEASE - - - org.apache.skywalking - apm-toolkit-trace - ${apm-toolkit-trace.version} - - - - - spring-retry-scenario - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${compiler.version} - ${compiler.version} - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-assembly-plugin - - - assemble - package - - single - - - - src/main/assembly/assembly.xml - - ./target/ - - - - - - - \ No newline at end of file diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/spring-retry-scenario/src/main/assembly/assembly.xml deleted file mode 100644 index eab9576b2b..0000000000 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/assembly/assembly.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - zip - - - - - ./bin - 0775 - - - - - - ${project.build.directory}/spring-retry-scenario.jar - ./libs - 0775 - - - diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/Application.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/Application.java deleted file mode 100644 index c9ba3b70cb..0000000000 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/Application.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 test.apache.skywalking.apm.testcase.spring.retry; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.retry.annotation.EnableRetry; - -@EnableAutoConfiguration -@Configuration -@ComponentScan -@EnableRetry -public class Application { - - public static void main(String[] args) { - try { - SpringApplication.run(Application.class, args); - } catch (Exception e) { - // Never do this - } - } - -} diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java deleted file mode 100644 index e3a94e5c9d..0000000000 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/controller/CaseController.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 test.apache.skywalking.apm.testcase.spring.retry.controller; - -import org.springframework.web.bind.annotation.ResponseBody; -import test.apache.skywalking.apm.testcase.spring.retry.service.CaseService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -@Controller -@ResponseBody -@RequestMapping("/case") -public class CaseController { - - @Autowired - private CaseService caseService; - - @RequestMapping("/healthCheck") - public String health() { - caseService.handle(); - return "success"; - } - -} diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java b/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java deleted file mode 100644 index e7421cf299..0000000000 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring/retry/service/CaseService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 test.apache.skywalking.apm.testcase.spring.retry.service; - -import org.apache.skywalking.apm.toolkit.trace.Trace; -import org.springframework.retry.annotation.Backoff; -import org.springframework.retry.annotation.Retryable; -import org.springframework.stereotype.Service; - -@Service -public class CaseService { - - @Retryable(value = Exception.class, backoff = @Backoff(delay = 1000, multiplier = 2)) - @Trace - public void handle() { - } - -} diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/resources/application.properties b/test/plugin/scenarios/spring-retry-scenario/src/main/resources/application.properties deleted file mode 100644 index bb0c9afd00..0000000000 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/resources/application.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# 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. -# -# -server.port=8080 -server.contextPath=/spring-retry-scenario diff --git a/test/plugin/scenarios/spring-retry-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/spring-retry-scenario/src/main/resources/log4j2.xml deleted file mode 100644 index 9849ed5a8a..0000000000 --- a/test/plugin/scenarios/spring-retry-scenario/src/main/resources/log4j2.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/plugin/scenarios/spring-retry-scenario/support-version.list b/test/plugin/scenarios/spring-retry-scenario/support-version.list deleted file mode 100644 index 97b610dc4a..0000000000 --- a/test/plugin/scenarios/spring-retry-scenario/support-version.list +++ /dev/null @@ -1,18 +0,0 @@ -# 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. - -1.4.1.RELEASE -1.5.16.RELEASE \ No newline at end of file From 232ea164a916e1c5cc08c8764a68e18064719073 Mon Sep 17 00:00:00 2001 From: wang Date: Tue, 29 Jul 2025 10:02:15 +0800 Subject: [PATCH 10/11] update comment word --- CHANGES.md | 2 ++ .../apm/plugin/spring/patch/AutoProxyCreatorInterceptor.java | 4 ++-- .../plugin/spring/patch/ProxyProcessorSupportInterceptor.java | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4f1bc7cee8..116241e4d8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,8 @@ Release Notes. * Support for tracking in lettuce versions 6.5.x and above. * Upgrade byte-buddy version to 1.17.6. * Support gRPC 1.59.x and 1.70.x server interceptor trace +* Fix the `CreateAopProxyInterceptor` in the Spring core-patch changes the AOP proxy type when a class is + enhanced by both SkyWalking and Spring AOP. All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/236?closed=1) diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutoProxyCreatorInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutoProxyCreatorInterceptor.java index 98326f9b38..943ac8983d 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutoProxyCreatorInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutoProxyCreatorInterceptor.java @@ -25,8 +25,8 @@ import java.lang.reflect.Method; /** - * AutoProxyCreatorInterceptor check that the bean has been implement {@link EnhancedInstance}. - * if yes, true will be returned. + * AutoProxyCreatorInterceptor determines whether the given interface is {@link EnhancedInstance}, + * and therefore does not consider it a reasonable proxy interface. */ public class AutoProxyCreatorInterceptor implements InstanceMethodsAroundInterceptor { diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/ProxyProcessorSupportInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/ProxyProcessorSupportInterceptor.java index 75ced4a0bd..d8840d4ef2 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/ProxyProcessorSupportInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/ProxyProcessorSupportInterceptor.java @@ -25,8 +25,8 @@ import java.lang.reflect.Method; /** - * ProxyProcessorSupportInterceptor check that the bean has been implement {@link EnhancedInstance}. - * if yes, true will be returned. + * ProxyProcessorSupportInterceptor determines whether the given interface is {@link EnhancedInstance}, + * and therefore does not consider it a reasonable proxy interface. */ public class ProxyProcessorSupportInterceptor implements InstanceMethodsAroundInterceptor { From 547bff2d6828c29518b8b888ba2a2c8664a61160 Mon Sep 17 00:00:00 2001 From: wang Date: Tue, 29 Jul 2025 10:16:22 +0800 Subject: [PATCH 11/11] add license header --- .../testcase/spring3/config/RetryConfig.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/config/RetryConfig.java b/test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/config/RetryConfig.java index 2e8de3308b..4d7d40d153 100644 --- a/test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/config/RetryConfig.java +++ b/test/plugin/scenarios/spring-4.1.x-scenario/src/main/java/test/apache/skywalking/apm/testcase/spring3/config/RetryConfig.java @@ -1,3 +1,21 @@ +/* + * 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 test.apache.skywalking.apm.testcase.spring3.config; import org.springframework.context.annotation.Configuration;