This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-java.git


The following commit(s) were added to refs/heads/main by this push:
     new 576550a8db Add witness class/method for resteasy-server plugin (#722)
576550a8db is described below

commit 576550a8db6e1f98bfd3746aacafb0acbc3922b4
Author: Leibniz.Hu <[email protected]>
AuthorDate: Mon Oct 28 18:07:29 2024 +0800

    Add witness class/method for resteasy-server plugin (#722)
---
 CHANGES.md                                             |  2 +-
 .../define/SynchronousDispatcherInstrumentation.java   |  5 +++++
 .../define/SynchronousDispatcherInstrumentation.java   | 18 ++++++++++++++++++
 .../define/SynchronousDispatcherInstrumentation.java   | 18 ++++++++++++++++++
 4 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/CHANGES.md b/CHANGES.md
index 57fd985098..270c4ab125 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -8,7 +8,7 @@ Release Notes.
 * Upgrade nats plugin to support 2.16.5
 * Add agent self-observability.
 * Fix intermittent ClassCircularityError by preloading ThreadLocalRandom since 
ByteBuddy 1.12.11
-
+* Add witness class/method for resteasy-server plugin(v3/v4/v6)
 
 All issues and pull requests are 
[here](https://github.com/apache/skywalking/milestone/222?closed=1)
 
diff --git 
a/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v3/server/define/SynchronousDispatcherInstrumentation.java
 
b/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v3/server/define/SynchronousDispatcherInstrumentation.java
index aaade19398..77093e85a8 100644
--- 
a/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v3/server/define/SynchronousDispatcherInstrumentation.java
+++ 
b/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v3/server/define/SynchronousDispatcherInstrumentation.java
@@ -83,4 +83,9 @@ public class SynchronousDispatcherInstrumentation extends 
ClassInstanceMethodsEn
     protected ClassMatch enhanceClass() {
         return NameMatch.byName(ENHANCE_CLASS);
     }
+
+    @Override
+    protected String[] witnessClasses() {
+        return new String[]{"org.jboss.resteasy.core.Dispatcher"};
+    }
 }
diff --git 
a/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v4/server/define/SynchronousDispatcherInstrumentation.java
 
b/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v4/server/define/SynchronousDispatcherInstrumentation.java
index 245994dc69..206af100d8 100644
--- 
a/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v4/server/define/SynchronousDispatcherInstrumentation.java
+++ 
b/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v4/server/define/SynchronousDispatcherInstrumentation.java
@@ -20,13 +20,18 @@ package 
org.apache.skywalking.apm.plugin.resteasy.v4.server.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;
+import static net.bytebuddy.matcher.ElementMatchers.returns;
 import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
 
 public class SynchronousDispatcherInstrumentation extends 
ClassInstanceMethodsEnhancePluginDefine {
@@ -83,4 +88,17 @@ public class SynchronousDispatcherInstrumentation extends 
ClassInstanceMethodsEn
     protected ClassMatch enhanceClass() {
         return NameMatch.byName(ENHANCE_CLASS);
     }
+
+    @Override
+    protected String[] witnessClasses() {
+        return new String[]{"org.jboss.resteasy.core.InternalDispatcher"};
+    }
+
+    @Override
+    protected List<WitnessMethod> witnessMethods() {
+        return Collections.singletonList(new WitnessMethod(
+            "org.jboss.resteasy.spi.Dispatcher",
+            
named("internalInvocation").and(returns(named("javax.ws.rs.core.Response")))
+        ));
+    }
 }
diff --git 
a/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v6/server/define/SynchronousDispatcherInstrumentation.java
 
b/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v6/server/define/SynchronousDispatcherInstrumentation.java
index c4a472487c..d38fb5775d 100644
--- 
a/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v6/server/define/SynchronousDispatcherInstrumentation.java
+++ 
b/apm-sniffer/apm-sdk-plugin/resteasy-plugin/resteasy-server-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/resteasy/v6/server/define/SynchronousDispatcherInstrumentation.java
@@ -20,13 +20,18 @@ package 
org.apache.skywalking.apm.plugin.resteasy.v6.server.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;
+import static net.bytebuddy.matcher.ElementMatchers.returns;
 import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
 
 public class SynchronousDispatcherInstrumentation extends 
ClassInstanceMethodsEnhancePluginDefine {
@@ -83,4 +88,17 @@ public class SynchronousDispatcherInstrumentation extends 
ClassInstanceMethodsEn
     protected ClassMatch enhanceClass() {
         return NameMatch.byName(ENHANCE_CLASS);
     }
+
+    @Override
+    protected String[] witnessClasses() {
+        return new String[]{"org.jboss.resteasy.core.InternalDispatcher"};
+    }
+
+    @Override
+    protected List<WitnessMethod> witnessMethods() {
+        return Collections.singletonList(new WitnessMethod(
+            "org.jboss.resteasy.spi.Dispatcher",
+            
named("internalInvocation").and(returns(named("jakarta.ws.rs.core.Response")))
+        ));
+    }
 }

Reply via email to