Add witness class/method for resteasy-server plugin (#722)

This commit is contained in:
Leibniz.Hu 2024-10-28 18:07:29 +08:00 committed by GitHub
parent 615a1b11bb
commit 576550a8db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 42 additions and 1 deletions

View File

@ -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)

View File

@ -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"};
}
}

View File

@ -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")))
));
}
}

View File

@ -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")))
));
}
}