Skip to content

Commit

Permalink
Add witness class/method for resteasy-server plugin (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leibnizhu authored Oct 28, 2024
1 parent 615a1b1 commit 576550a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ public boolean isOverrideArgs() {
protected ClassMatch enhanceClass() {
return NameMatch.byName(ENHANCE_CLASS);
}

@Override
protected String[] witnessClasses() {
return new String[]{"org.jboss.resteasy.core.Dispatcher"};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@

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 {
Expand Down Expand Up @@ -83,4 +88,17 @@ public boolean isOverrideArgs() {
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")))
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@

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 {
Expand Down Expand Up @@ -83,4 +88,17 @@ public boolean isOverrideArgs() {
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")))
));
}
}

0 comments on commit 576550a

Please sign in to comment.