change: nutz http plugins split into three Instrumentation
change: use ElementMatchers.takesArguments to match Sender(Request)
This commit is contained in:
parent
e68d48a6d4
commit
5934158902
|
|
@ -6,24 +6,13 @@ import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoin
|
|||
import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
|
||||
import org.skywalking.apm.agent.core.plugin.match.HierarchyMatch;
|
||||
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
|
||||
/**
|
||||
* {@link NutzHttpInstrumentation} enhance the <code>send</code>
|
||||
* method,<code>Constructor</code> of <code>org.nutz.http.Sender</code> by
|
||||
* <code>org.skywalking.apm.plugin.nutz.http.sync.SenderConstructorInterceptor</code>, and
|
||||
* <code>org.skywalking.apm.plugin.nutz.http.sync.SenderSendInterceptor</code>
|
||||
* set context to header for propagate trace context around execute
|
||||
* <code>send</code>.
|
||||
*
|
||||
* @author wendal
|
||||
*/
|
||||
public class NutzHttpInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
public abstract class AbstractNutzHttpInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
||||
private static final String ENHANCE_CLASS = "org.nutz.http.Sender";
|
||||
private static final String DO_SEND_METHOD_NAME = "send";
|
||||
private static final String DO_SEND_INTERCEPTOR = "org.skywalking.apm.plugin.nutz.http.sync.SenderSendInterceptor";
|
||||
private static final String DO_CONSTRUCTOR_INTERCEPTOR = "org.skywalking.apm.plugin.nutz.http.sync.SenderConstructorInterceptor";
|
||||
|
|
@ -34,14 +23,9 @@ public class NutzHttpInstrumentation extends ClassInstanceMethodsEnhancePluginDe
|
|||
new ConstructorInterceptPoint() {
|
||||
@Override
|
||||
public ElementMatcher<MethodDescription> getConstructorMatcher() {
|
||||
return new ElementMatcher<MethodDescription>() {
|
||||
@Override
|
||||
public boolean matches(MethodDescription target) {
|
||||
return target.isConstructor() && target.getParameters().size() > 0;
|
||||
}
|
||||
};
|
||||
return ElementMatchers.takesArguments(1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getConstructorInterceptor() {
|
||||
return DO_CONSTRUCTOR_INTERCEPTOR;
|
||||
|
|
@ -58,12 +42,12 @@ public class NutzHttpInstrumentation extends ClassInstanceMethodsEnhancePluginDe
|
|||
public ElementMatcher<MethodDescription> getMethodsMatcher() {
|
||||
return named(DO_SEND_METHOD_NAME);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return DO_SEND_INTERCEPTOR;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isOverrideArgs() {
|
||||
return false;
|
||||
|
|
@ -72,8 +56,5 @@ public class NutzHttpInstrumentation extends ClassInstanceMethodsEnhancePluginDe
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassMatch enhanceClass() {
|
||||
return HierarchyMatch.byHierarchyMatch(new String[]{ENHANCE_CLASS});
|
||||
}
|
||||
}
|
||||
protected abstract ClassMatch enhanceClass();
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package org.skywalking.apm.plugin.nutz.http.sync.define;
|
||||
|
||||
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
|
||||
import org.skywalking.apm.agent.core.plugin.match.NameMatch;
|
||||
|
||||
public class NutzHttpFilePostSenderInstrumentation extends AbstractNutzHttpInstrumentation {
|
||||
|
||||
protected ClassMatch enhanceClass() {
|
||||
return NameMatch.byName("org.nutz.http.sender.FilePostSender");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package org.skywalking.apm.plugin.nutz.http.sync.define;
|
||||
|
||||
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
|
||||
import org.skywalking.apm.agent.core.plugin.match.NameMatch;
|
||||
|
||||
public class NutzHttpGetSenderInstrumentation extends AbstractNutzHttpInstrumentation {
|
||||
|
||||
@Override
|
||||
protected ClassMatch enhanceClass() {
|
||||
return NameMatch.byName("org.nutz.http.sender.GetSender");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package org.skywalking.apm.plugin.nutz.http.sync.define;
|
||||
|
||||
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
|
||||
import org.skywalking.apm.agent.core.plugin.match.NameMatch;
|
||||
|
||||
|
||||
public class NutzHttpPostSenderInstrumentation extends AbstractNutzHttpInstrumentation {
|
||||
|
||||
@Override
|
||||
protected ClassMatch enhanceClass() {
|
||||
return NameMatch.byName("org.nutz.http.sender.PostSender");
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1,3 @@
|
|||
nutz-http-1.x=org.skywalking.apm.plugin.nutz.http.sync.define.NutzHttpInstrumentation
|
||||
nutz-http-1.x=org.skywalking.apm.plugin.nutz.http.sync.define.NutzHttpGetSenderInstrumentation
|
||||
nutz-http-1.x=org.skywalking.apm.plugin.nutz.http.sync.define.NutzHttpPostSenderInstrumentation
|
||||
nutz-http-1.x=org.skywalking.apm.plugin.nutz.http.sync.define.NutzHttpFilePostSenderInstrumentation
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* The <code>PathMappingCache</code> represents a field
|
||||
*
|
||||
*
|
||||
* @author wusheng
|
||||
* @author wendal
|
||||
*/
|
||||
public class PathMappingCache {
|
||||
private String classPath = "";
|
||||
|
|
|
|||
Loading…
Reference in New Issue