Skip to content

Commit 576550a

Browse files
authored
Add witness class/method for resteasy-server plugin (#722)
1 parent 615a1b1 commit 576550a

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Release Notes.
88
* Upgrade nats plugin to support 2.16.5
99
* Add agent self-observability.
1010
* Fix intermittent ClassCircularityError by preloading ThreadLocalRandom since ByteBuddy 1.12.11
11-
11+
* Add witness class/method for resteasy-server plugin(v3/v4/v6)
1212

1313
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/222?closed=1)
1414

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,9 @@ public boolean isOverrideArgs() {
8383
protected ClassMatch enhanceClass() {
8484
return NameMatch.byName(ENHANCE_CLASS);
8585
}
86+
87+
@Override
88+
protected String[] witnessClasses() {
89+
return new String[]{"org.jboss.resteasy.core.Dispatcher"};
90+
}
8691
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@
2020

2121
import net.bytebuddy.description.method.MethodDescription;
2222
import net.bytebuddy.matcher.ElementMatcher;
23+
import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod;
2324
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
2425
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
2526
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
2627
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
2728
import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
2829

30+
import java.util.Collections;
31+
import java.util.List;
32+
2933
import static net.bytebuddy.matcher.ElementMatchers.named;
34+
import static net.bytebuddy.matcher.ElementMatchers.returns;
3035
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
3136

3237
public class SynchronousDispatcherInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
@@ -83,4 +88,17 @@ public boolean isOverrideArgs() {
8388
protected ClassMatch enhanceClass() {
8489
return NameMatch.byName(ENHANCE_CLASS);
8590
}
91+
92+
@Override
93+
protected String[] witnessClasses() {
94+
return new String[]{"org.jboss.resteasy.core.InternalDispatcher"};
95+
}
96+
97+
@Override
98+
protected List<WitnessMethod> witnessMethods() {
99+
return Collections.singletonList(new WitnessMethod(
100+
"org.jboss.resteasy.spi.Dispatcher",
101+
named("internalInvocation").and(returns(named("javax.ws.rs.core.Response")))
102+
));
103+
}
86104
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@
2020

2121
import net.bytebuddy.description.method.MethodDescription;
2222
import net.bytebuddy.matcher.ElementMatcher;
23+
import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod;
2324
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
2425
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
2526
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
2627
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
2728
import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
2829

30+
import java.util.Collections;
31+
import java.util.List;
32+
2933
import static net.bytebuddy.matcher.ElementMatchers.named;
34+
import static net.bytebuddy.matcher.ElementMatchers.returns;
3035
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
3136

3237
public class SynchronousDispatcherInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
@@ -83,4 +88,17 @@ public boolean isOverrideArgs() {
8388
protected ClassMatch enhanceClass() {
8489
return NameMatch.byName(ENHANCE_CLASS);
8590
}
91+
92+
@Override
93+
protected String[] witnessClasses() {
94+
return new String[]{"org.jboss.resteasy.core.InternalDispatcher"};
95+
}
96+
97+
@Override
98+
protected List<WitnessMethod> witnessMethods() {
99+
return Collections.singletonList(new WitnessMethod(
100+
"org.jboss.resteasy.spi.Dispatcher",
101+
named("internalInvocation").and(returns(named("jakarta.ws.rs.core.Response")))
102+
));
103+
}
86104
}

0 commit comments

Comments
 (0)