fix: let nutz-plugins compatible with 3.2.1-2017
change: using ContextCarrier.items() in 3.2.1-2017 remove: useless javadoc in nutz-plugins
This commit is contained in:
parent
7597b0f067
commit
05bcf2b6dd
|
|
@ -3,7 +3,7 @@
|
|||
<parent>
|
||||
<artifactId>nutz-plugins</artifactId>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<version>3.2-2017</version>
|
||||
<version>3.2.1-2017</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import java.net.URI;
|
|||
import org.nutz.http.Request;
|
||||
import org.nutz.http.Request.METHOD;
|
||||
import org.nutz.http.Response;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.CarrierItem;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
|
@ -34,7 +34,11 @@ public class SenderSendInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
Tags.HTTP.METHOD.set(span, httpMethod.toString());
|
||||
SpanLayer.asHttp(span);
|
||||
|
||||
req.getHeader().set(Config.Plugin.Propagation.HEADER_NAME, contextCarrier.serialize());
|
||||
CarrierItem next = contextCarrier.items();
|
||||
while (next.hasNext()) {
|
||||
next = next.next();
|
||||
req.getHeader().set(next.getHeadKey(), next.getHeadValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<parent>
|
||||
<artifactId>nutz-plugins</artifactId>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<version>3.2-2017</version>
|
||||
<version>3.2.1-2017</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,19 +5,10 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
|
|||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
|
||||
|
||||
/**
|
||||
* The <code>ControllerConstructorInterceptor</code> intercepts the Controller's constructor, in order to acquire the
|
||||
* mapping annotation, if exist.
|
||||
*
|
||||
* But, you can see we only use the first mapping value, <B>Why?</B>
|
||||
*
|
||||
* Right now, we intercept the controller by annotation as you known, so we CAN'T know which uri patten is actually
|
||||
* matched. Even we know, that costs a lot.
|
||||
*
|
||||
* If we want to resolve that, we must intercept the Nutz MVC core codes, that is not a good choice for now.
|
||||
*
|
||||
* Comment by @wu-sheng
|
||||
* @author wendal
|
||||
*/
|
||||
public class ControllerConstructorInterceptor implements InstanceConstructorInterceptor {
|
||||
public class ActionConstructorInterceptor implements InstanceConstructorInterceptor {
|
||||
|
||||
@Override
|
||||
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
|
||||
|
|
@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.nutz.mvc.Mvcs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.CarrierItem;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
|
@ -19,11 +19,12 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptR
|
|||
import org.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
|
||||
/**
|
||||
* The <code>ControllerServiceMethodInterceptor</code> only use the first mapping value.
|
||||
* The <code>ActionMethodInterceptor</code> only use the first mapping value.
|
||||
*
|
||||
* @See {@link ControllerConstructorInterceptor} to explain why we are doing this.
|
||||
* @See {@link ActionConstructorInterceptor} to explain why we are doing this.
|
||||
* @author wendal
|
||||
*/
|
||||
public class ControllerServiceMethodInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
public class ActionMethodInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
|
|
@ -41,8 +42,12 @@ public class ControllerServiceMethodInterceptor implements InstanceMethodsAround
|
|||
}
|
||||
|
||||
HttpServletRequest request = Mvcs.getReq();
|
||||
String tracingHeaderValue = request.getHeader(Config.Plugin.Propagation.HEADER_NAME);
|
||||
ContextCarrier contextCarrier = new ContextCarrier().deserialize(tracingHeaderValue);
|
||||
ContextCarrier contextCarrier = new ContextCarrier();
|
||||
CarrierItem next = contextCarrier.items();
|
||||
while (next.hasNext()) {
|
||||
next = next.next();
|
||||
next.setHeadValue(request.getHeader(next.getHeadKey()));
|
||||
}
|
||||
AbstractSpan span = ContextManager.createEntrySpan(requestURL, contextCarrier);
|
||||
Tags.URL.set(span, request.getRequestURL().toString());
|
||||
Tags.HTTP.METHOD.set(span, request.getMethod());
|
||||
|
|
@ -1,22 +1,22 @@
|
|||
package org.skywalking.apm.plugin.nutz.mvc.define;
|
||||
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
|
||||
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 static net.bytebuddy.matcher.ElementMatchers.any;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static org.skywalking.apm.agent.core.plugin.match.ClassAnnotationMatch.byClassAnnotationMatch;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author wendal
|
||||
*/
|
||||
public abstract class AbstractControllerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
|
||||
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 net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
public class ActionInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
||||
public static final String ENHANCE_ANNOTATION = "org.nutz.mvc.annotation.At";
|
||||
|
||||
@Override
|
||||
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
|
||||
return new ConstructorInterceptPoint[] {
|
||||
|
|
@ -28,7 +28,7 @@ public abstract class AbstractControllerInstrumentation extends ClassInstanceMet
|
|||
|
||||
@Override
|
||||
public String getConstructorInterceptor() {
|
||||
return "org.skywalking.apm.plugin.nutz.mvc.ControllerConstructorInterceptor";
|
||||
return "org.skywalking.apm.plugin.nutz.mvc.ActionConstructorInterceptor";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -45,7 +45,7 @@ public abstract class AbstractControllerInstrumentation extends ClassInstanceMet
|
|||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return "org.skywalking.apm.plugin.nutz.mvc.ControllerServiceMethodInterceptor";
|
||||
return "org.skywalking.apm.plugin.nutz.mvc.ActionMethodInterceptor";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -61,5 +61,7 @@ public abstract class AbstractControllerInstrumentation extends ClassInstanceMet
|
|||
return byClassAnnotationMatch(getEnhanceAnnotations());
|
||||
}
|
||||
|
||||
protected abstract String[] getEnhanceAnnotations();
|
||||
protected String[] getEnhanceAnnotations() {
|
||||
return new String[] {ENHANCE_ANNOTATION};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package org.skywalking.apm.plugin.nutz.mvc.define;
|
||||
|
||||
public class ControllerInstrumentation extends AbstractControllerInstrumentation {
|
||||
|
||||
public static final String ENHANCE_ANNOTATION = "org.nutz.mvc.annotation.At";
|
||||
|
||||
@Override protected String[] getEnhanceAnnotations() {
|
||||
return new String[] {ENHANCE_ANNOTATION};
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
nutz-mvc-annotation-1.x=org.skywalking.apm.plugin.nutz.mvc.define.ControllerInstrumentation
|
||||
nutz-mvc-annotation-1.x=org.skywalking.apm.plugin.nutz.mvc.define.ActionInstrumentation
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
<parent>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-sdk-plugin</artifactId>
|
||||
<version>3.2-2017</version>
|
||||
<version>3.2.1-2017</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>nutz-plugins</artifactId>
|
||||
|
|
|
|||
Loading…
Reference in New Issue