1. 提交Tomcat插件,支持7.x-8.x
2. 修复错误类名(InstanceMethodsAroundInterceptor)
This commit is contained in:
parent
9ec5a46425
commit
e8b4d26830
|
|
@ -1,53 +0,0 @@
|
|||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
.idea/
|
||||
samples/skywalking-auth/skywalking-auth.iml
|
||||
samples/skywalking-auth/target/
|
||||
skywalking-alarm/skywalking-alarm.iml
|
||||
skywalking-alarm/target/
|
||||
skywalking-analysis/skywalking-analysis.iml
|
||||
skywalking-analysis/target/
|
||||
skywalking-collector/skywalking-agent/dependency-reduced-pom.xml
|
||||
skywalking-collector/skywalking-agent/skywalking-agent.iml
|
||||
skywalking-collector/skywalking-agent/target/
|
||||
skywalking-collector/skywalking-api/skywalking-api.iml
|
||||
skywalking-collector/skywalking-collector.iml
|
||||
skywalking-collector/skywalking-log/example/example.iml
|
||||
skywalking-collector/skywalking-log/log4j-1.x-plugin/skywalking-log4j-1.x-plugin.iml
|
||||
skywalking-collector/skywalking-log/log4j-2.x-plugin/skywalking-log4j-2.x-plugin.iml
|
||||
skywalking-collector/skywalking-log/skywalking-log.iml
|
||||
skywalking-collector/skywalking-protocol/skywalking-protocol.iml
|
||||
skywalking-collector/skywalking-sdk-plugin/dubbo-plugin/skywalking-dubbo-plugin.iml
|
||||
skywalking-collector/skywalking-sdk-plugin/dubbo-plugin/target/
|
||||
skywalking-collector/skywalking-sdk-plugin/httpClient-4.x-plugin/skywalking-httpClient-4.x-plugin.iml
|
||||
skywalking-collector/skywalking-sdk-plugin/httpClient-4.x-plugin/target/
|
||||
skywalking-collector/skywalking-sdk-plugin/jdbc-plugin/skywalking-jdbc-plugin.iml
|
||||
skywalking-sdk-plugin/jdbc-plugin/target/
|
||||
skywalking-collector/skywalking-sdk-plugin/jedis-2.x-plugin/skywalking-jedis-2.x-plugin.iml
|
||||
skywalking-collector/skywalking-sdk-plugin/jedis-2.x-plugin/target/
|
||||
skywalking-collector/skywalking-sdk-plugin/spring-plugin/skywalking-spring-plugin.iml
|
||||
skywalking-collector/skywalking-sdk-plugin/spring-plugin/target/
|
||||
skywalking-collector/skywalking-sdk-plugin/web-plugin/skywalking-web-plugin.iml
|
||||
skywalking-collector/skywalking-sdk-plugin/web-plugin/target/
|
||||
skywalking-server/target/
|
||||
skywalking-webui/skywalking-webui.iml
|
||||
skywalking.iml
|
||||
test/skywalking-agent-test/.idea/
|
||||
test/skywalking-agent-test/dubbo-test/
|
||||
test/skywalking-agent-test/jdbc-test/jdbc-test.iml
|
||||
test/skywalking-agent-test/redis-test/redis-test.iml
|
||||
test/skywalking-test-api/skywalking-test-api.iml
|
||||
test/skywalking-test-api/target/
|
||||
skywalking-collector/skywalking-sdk-plugin/jdbc-plugin/target/
|
||||
.gitignore
|
||||
skywalking-collector/skywalking-log/logback-plugin/logback-plugin.iml
|
||||
|
|
@ -23,6 +23,10 @@
|
|||
<shade.io.netty.target>com.ai.cloud.skywalking.api.dependencies.io.netty</shade.io.netty.target>
|
||||
<shade.com.google.protobuf.source>com.google.protobuf</shade.com.google.protobuf.source>
|
||||
<shade.com.google.protobuf.target>com.ai.cloud.skywalking.api.dependencies.google.protobuf</shade.com.google.protobuf.target>
|
||||
<shade.javassist.source>javassist</shade.javassist.source>
|
||||
<shade.javassist.target>com.ai.cloud.skywalking.api.dependencies.javassist</shade.javassist.target>
|
||||
<shade.com.google.gson.source>com.google.gson</shade.com.google.gson.source>
|
||||
<shade.com.google.gson.target>com.ai.cloud.skywalking.api.dependencies.com.google.gson</shade.com.google.gson.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
@ -46,6 +50,11 @@
|
|||
<artifactId>skywalking-dubbo-plugin</artifactId>
|
||||
<version>1.0-Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ai.cloud</groupId>
|
||||
<artifactId>tomcat-8.x-plugin</artifactId>
|
||||
<version>1.0-Final</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
@ -88,6 +97,14 @@
|
|||
<pattern>${shade.com.google.protobuf.source}</pattern>
|
||||
<shadedPattern>${shade.com.google.protobuf.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.javassist.source}</pattern>
|
||||
<shadedPattern>${shade.javassist.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.com.google.gson.source}</pattern>
|
||||
<shadedPattern>${shade.com.google.gson.target}</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
|||
|
|
@ -32,12 +32,10 @@ public abstract class BaseInvokeMonitor {
|
|||
}
|
||||
|
||||
|
||||
if (!spanData.isValidate()) {
|
||||
// 根据SpanData生成RequestSpan,并保存
|
||||
ContextBuffer.save(RequestSpan.RequestSpanBuilder.
|
||||
newBuilder(spanData).callType(id.getCallType()).viewPoint(id.getViewPoint())
|
||||
.spanTypeDesc(id.getSpanTypeDesc()).build());
|
||||
}
|
||||
|
||||
// 将新创建的Context存放到ThreadLocal栈中。
|
||||
CurrentThreadSpanStack.push(spanData);
|
||||
|
|
@ -56,10 +54,6 @@ public abstract class BaseInvokeMonitor {
|
|||
|
||||
// 弹出上下文的栈顶中的元素
|
||||
Span spanData = CurrentThreadSpanStack.pop();
|
||||
if (spanData == null || spanData.isValidate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
spanData.setInvokeResult(invokeResult);
|
||||
|
||||
if (Config.BuriedPoint.PRINTF) {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ public class RPCServerInvokeMonitor extends BaseInvokeMonitor {
|
|||
// 设置是否为接收端
|
||||
spanData.setSpanType(SpanType.RPC_SERVER);
|
||||
|
||||
invalidateAllSpanIfIsNotFirstSpan(spanData);
|
||||
|
||||
super.beforeInvoke(spanData, id);
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
|
|
@ -42,9 +40,4 @@ public class RPCServerInvokeMonitor extends BaseInvokeMonitor {
|
|||
super.occurException(th);
|
||||
}
|
||||
|
||||
private void invalidateAllSpanIfIsNotFirstSpan(Span spanData) {
|
||||
if (!CurrentThreadSpanStack.peek().getTraceId().equals(spanData.getTraceId())) {
|
||||
CurrentThreadSpanStack.invalidatePresentSpans();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.InterceptorException;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.IntanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
|
||||
/**
|
||||
* 用于首次拦截方法调用,避免方法内部的方法调用被多次拦截。
|
||||
|
|
@ -12,7 +12,7 @@ import com.ai.cloud.skywalking.plugin.interceptor.enhance.IntanceMethodsAroundIn
|
|||
* @author wusheng
|
||||
*
|
||||
*/
|
||||
public abstract class SimpleObjectFirstInvokeInterceptor implements IntanceMethodsAroundInterceptor {
|
||||
public abstract class SimpleObjectFirstInvokeInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
protected String invokeCounterKey = "__$invokeCounterKey";
|
||||
|
||||
protected Object invokeCounterInstLock = new Object();
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ public class ClassConstructorInterceptor {
|
|||
private static Logger logger = LogManager
|
||||
.getLogger(ClassConstructorInterceptor.class);
|
||||
|
||||
private IntanceMethodsAroundInterceptor interceptor;
|
||||
private InstanceMethodsAroundInterceptor interceptor;
|
||||
|
||||
public ClassConstructorInterceptor(IntanceMethodsAroundInterceptor interceptor) {
|
||||
public ClassConstructorInterceptor(InstanceMethodsAroundInterceptor interceptor) {
|
||||
this.interceptor = interceptor;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
|
|||
* 2.intercept constructor by default, and intercept method which it's
|
||||
* required by interceptorDefineClass. <br/>
|
||||
*/
|
||||
IntanceMethodsAroundInterceptor interceptor = getInstanceMethodsInterceptor();
|
||||
InstanceMethodsAroundInterceptor interceptor = getInstanceMethodsInterceptor();
|
||||
if (interceptor == null) {
|
||||
throw new EnhanceException("no IntanceMethodsAroundInterceptor instance. ");
|
||||
throw new EnhanceException("no InstanceMethodsAroundInterceptor instance. ");
|
||||
}
|
||||
|
||||
newClassBuilder = newClassBuilder
|
||||
|
|
@ -116,7 +116,7 @@ public abstract class ClassEnhancePluginDefine extends AbstractClassEnhancePlugi
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract IntanceMethodsAroundInterceptor getInstanceMethodsInterceptor();
|
||||
protected abstract InstanceMethodsAroundInterceptor getInstanceMethodsInterceptor();
|
||||
|
||||
private DynamicType.Builder<?> enhanceClass(String enhanceOriginClassName,
|
||||
DynamicType.Builder<?> newClassBuilder) throws PluginException {
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ public class ClassInstanceMethodsInterceptor {
|
|||
private static Logger logger = LogManager
|
||||
.getLogger(ClassInstanceMethodsInterceptor.class);
|
||||
|
||||
private IntanceMethodsAroundInterceptor interceptor;
|
||||
private InstanceMethodsAroundInterceptor interceptor;
|
||||
|
||||
public ClassInstanceMethodsInterceptor(IntanceMethodsAroundInterceptor interceptor) {
|
||||
public ClassInstanceMethodsInterceptor(InstanceMethodsAroundInterceptor interceptor) {
|
||||
this.interceptor = interceptor;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public abstract class ClassStaticMethodsEnhancePluginDefine extends
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IntanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
protected InstanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.ai.cloud.skywalking.plugin.interceptor.enhance;
|
|||
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
|
||||
public interface IntanceMethodsAroundInterceptor {
|
||||
public interface InstanceMethodsAroundInterceptor {
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext);
|
||||
|
||||
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result);
|
||||
|
|
@ -59,14 +59,6 @@ public final class ContextGenerator {
|
|||
// LevelId是由SpanNode类的nextSubSpanLevelId字段进行初始化的.
|
||||
// 所以在这里不需要初始化
|
||||
span = new Span(parentSpan.getTraceId(), Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USER_ID);
|
||||
|
||||
// check parent span is RPC span
|
||||
// if true, current span is invalidate and current span also belong to RPC span
|
||||
if (parentSpan.isRPCClientSpan()) {
|
||||
span.setSpanType(SpanType.RPC_CLIENT);
|
||||
span.setValidate(false);
|
||||
}
|
||||
|
||||
if (!StringUtil.isEmpty(parentSpan.getParentLevel())) {
|
||||
span.setParentLevel(parentSpan.getParentLevel() + "." + parentSpan.getLevelId());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ package test.ai.cloud.matcher;
|
|||
import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.IntanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
|
||||
/**
|
||||
* Created by xin on 16-6-8.
|
||||
*/
|
||||
public class TestAroundInterceptor implements IntanceMethodsAroundInterceptor {
|
||||
public class TestAroundInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package test.ai.cloud.matcher;
|
|||
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.IntanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.matcher.PrivateMethodMatcher;
|
||||
|
||||
/**
|
||||
|
|
@ -28,7 +28,7 @@ public class TestMatcherDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IntanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
protected InstanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
return new TestAroundInterceptor();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ package test.ai.cloud.plugin;
|
|||
import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.IntanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
|
||||
public class TestAroundInterceptor implements IntanceMethodsAroundInterceptor {
|
||||
public class TestAroundInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package test.ai.cloud.plugin;
|
|||
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.ClassEnhancePluginDefine;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.IntanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ public class TestInterceptorDefine extends ClassEnhancePluginDefine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IntanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
public InstanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
return new TestAroundInterceptor();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ import com.ai.cloud.skywalking.model.Identification;
|
|||
import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.IntanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
|
||||
public class HttpClientExecuteInterceptor implements IntanceMethodsAroundInterceptor {
|
||||
public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
/**
|
||||
* default headname of sky walking context<br/>
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ package com.ai.cloud.skywalking.httpClient.v4.plugin.define;
|
|||
import com.ai.cloud.skywalking.httpClient.v4.plugin.HttpClientExecuteInterceptor;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.IntanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
|
||||
public abstract class HttpClientPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
||||
@Override
|
||||
public IntanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
public InstanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
return new HttpClientExecuteInterceptor();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,12 +20,6 @@
|
|||
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ai.cloud</groupId>
|
||||
<artifactId>skywalking-api</artifactId>
|
||||
<version>1.0-Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.ai.cloud.skywalking.jedis.v2.plugin.define;
|
|||
import com.ai.cloud.skywalking.jedis.v2.plugin.JedisClusterInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.IntanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.matcher.AnyMethodsMatcher;
|
||||
|
||||
public class JedisClusterPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
|
@ -21,7 +21,7 @@ public class JedisClusterPluginDefine extends ClassInstanceMethodsEnhancePluginD
|
|||
}
|
||||
|
||||
@Override
|
||||
public IntanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
public InstanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
return new JedisClusterInterceptor();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.ai.cloud.skywalking.jedis.v2.plugin.define;
|
|||
import com.ai.cloud.skywalking.jedis.v2.plugin.JedisInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.IntanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.matcher.MethodsExclusiveMatcher;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.matcher.PrivateMethodMatcher;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
|
|
@ -32,7 +32,7 @@ public class JedisPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IntanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
public InstanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
return new JedisInterceptor();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
<module>web-plugin</module>
|
||||
<module>httpClient-4.x-plugin</module>
|
||||
<module>jedis-2.x-plugin</module>
|
||||
<module>tomcat-7.x-8.x-plugin</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
|
@ -35,6 +36,11 @@
|
|||
<version>1.0-Final</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ai.cloud</groupId>
|
||||
<artifactId>skywalking-api</artifactId>
|
||||
<version>1.0-Final</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>skywalking-sdk-plugin</artifactId>
|
||||
<groupId>com.ai.cloud</groupId>
|
||||
<version>1.0-Final</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>tomcat-7.x-8.x-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>tomcat-7.x-8.x-plugin</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<tomcat.version>8.0.36</tomcat.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
<version>${tomcat.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-logging-juli</artifactId>
|
||||
<version>${tomcat.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-jasper</artifactId>
|
||||
<version>${tomcat.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.ai.cloud.skywalking.plugin.tomcat78x;
|
||||
|
||||
import com.ai.cloud.skywalking.api.Tracing;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.RPCServerInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.model.ContextData;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class TomcatPluginInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
private final String secondKey = "ContextData";
|
||||
private String tracingName = DEFAULT_TRACE_NAME;
|
||||
private static final String DEFAULT_TRACE_NAME = "SkyWalking-TRACING-NAME";
|
||||
private static final String TRACE_ID_HEADER_NAME = "SW-TraceId";
|
||||
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
|
||||
//DO Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
|
||||
Object[] args = interceptorContext.allArguments();
|
||||
HttpServletRequest requests = (HttpServletRequest) args[0];
|
||||
String tracingHeaderValue = requests.getHeader(tracingName);
|
||||
ContextData contextData = null;
|
||||
if (tracingHeaderValue != null) {
|
||||
String contextDataStr = null;
|
||||
int index = tracingHeaderValue.indexOf("=");
|
||||
if (index > 0) {
|
||||
String key = tracingHeaderValue.substring(0, index);
|
||||
if (secondKey.equals(key)) {
|
||||
contextDataStr = tracingHeaderValue.substring(index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (contextDataStr != null && contextDataStr.length() > 0) {
|
||||
contextData = new ContextData(contextDataStr);
|
||||
}
|
||||
}
|
||||
RPCServerInvokeMonitor rpcServerInvokeMonitor = new RPCServerInvokeMonitor();
|
||||
rpcServerInvokeMonitor.beforeInvoke(contextData, generateIdentification(requests));
|
||||
}
|
||||
|
||||
|
||||
private Identification generateIdentification(HttpServletRequest request) {
|
||||
return Identification.newBuilder()
|
||||
.viewPoint(request.getRequestURL().toString())
|
||||
.spanType(WebBuriedPointType.instance())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
|
||||
Object[] args = interceptorContext.allArguments();
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) args[1];
|
||||
httpServletResponse.addHeader(TRACE_ID_HEADER_NAME, Tracing.getTraceId());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
|
||||
// DO Nothing
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.ai.cloud.skywalking.plugin.tomcat78x;
|
||||
|
||||
import com.ai.cloud.skywalking.api.IBuriedPointType;
|
||||
import com.ai.cloud.skywalking.protocol.common.CallType;
|
||||
|
||||
public class WebBuriedPointType implements IBuriedPointType {
|
||||
|
||||
private static WebBuriedPointType webBuriedPointType;
|
||||
|
||||
public static IBuriedPointType instance() {
|
||||
if (webBuriedPointType == null) {
|
||||
webBuriedPointType = new WebBuriedPointType();
|
||||
}
|
||||
|
||||
return webBuriedPointType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "W";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallType getCallType() {
|
||||
return CallType.SYNC;
|
||||
}
|
||||
|
||||
private WebBuriedPointType() {
|
||||
// Non
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.ai.cloud.skywalking.plugin.tomcat78x.define;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
import com.ai.cloud.skywalking.plugin.tomcat78x.TomcatPluginInterceptor;
|
||||
import org.apache.catalina.connector.Request;
|
||||
import org.apache.catalina.connector.Response;
|
||||
|
||||
public class TomcatPluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
@Override
|
||||
protected MethodMatcher[] getInstanceMethodsMatchers() {
|
||||
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("invoke", Request.class, Response.class)};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InstanceMethodsAroundInterceptor getInstanceMethodsInterceptor() {
|
||||
return new TomcatPluginInterceptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String enhanceClassName() {
|
||||
return "org.apache.catalina.core.StandardEngineValve";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
com.ai.cloud.skywalking.plugin.tomcat78x.define.TomcatPluginDefine
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package test.com.ai.cloud.skywalking.plugin.tomcat78x;
|
||||
|
||||
import org.apache.catalina.LifecycleException;
|
||||
import org.apache.catalina.WebResourceRoot;
|
||||
import org.apache.catalina.core.StandardContext;
|
||||
import org.apache.catalina.startup.Tomcat;
|
||||
import org.apache.catalina.webresources.DirResourceSet;
|
||||
import org.apache.catalina.webresources.StandardRoot;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.File;
|
||||
|
||||
public class EmbedTomcat {
|
||||
|
||||
@Test
|
||||
public void testGetResourcePath(){
|
||||
System.out.println(EmbedTomcat.class.getResource("/").getPath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartTomcat() throws ServletException, LifecycleException {
|
||||
start();
|
||||
}
|
||||
|
||||
public static void start() throws ServletException, LifecycleException {
|
||||
String webappDirLocation = EmbedTomcat.class.getResource("/").getPath() + "webapp/";
|
||||
Tomcat tomcat = new Tomcat();
|
||||
tomcat.setPort(8080);
|
||||
|
||||
StandardContext standardContext = (StandardContext) tomcat.addWebapp("/",new File(webappDirLocation).getAbsolutePath());
|
||||
File additionWebInfClasses = new File(EmbedTomcat.class.getResource("/").getPath());
|
||||
WebResourceRoot resourceRoot = new StandardRoot(standardContext);
|
||||
resourceRoot.addPreResources(new DirResourceSet(resourceRoot,"/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/"));
|
||||
standardContext.setResources(resourceRoot);
|
||||
|
||||
tomcat.start();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package test.com.ai.cloud.skywalking.plugin.tomcat78x;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
import com.ai.skywalking.testframework.api.RequestSpanAssert;
|
||||
import org.apache.catalina.LifecycleException;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.ResponseHandler;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class TomcatPluginTest {
|
||||
|
||||
@Test
|
||||
public void test() throws InvocationTargetException, NoSuchMethodException, ClassNotFoundException, IllegalAccessException {
|
||||
TracingBootstrap
|
||||
.main(new String[]{TomcatPluginTest.class.getName()});
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ServletException, LifecycleException, IOException, InterruptedException {
|
||||
// start tomcat
|
||||
EmbedTomcat.start();
|
||||
// curl httpclient
|
||||
visitURL("http://127.0.0.1:8080/hello");
|
||||
// assert client
|
||||
RequestSpanAssert.assertEquals(new String[][]{
|
||||
{"0", "http://127.0.0.1:8080/hello" , ""}
|
||||
});
|
||||
}
|
||||
|
||||
public static void visitURL(String url) throws IOException {
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
try {
|
||||
HttpGet httpget = new HttpGet(url);
|
||||
ResponseHandler<String> responseHandler = new ResponseHandler<String>() {
|
||||
@Override
|
||||
public String handleResponse(
|
||||
final HttpResponse response) throws ClientProtocolException, IOException {
|
||||
int status = response.getStatusLine().getStatusCode();
|
||||
if (status >= 200 && status < 300) {
|
||||
HttpEntity entity = response.getEntity();
|
||||
return entity != null ? EntityUtils.toString(entity) : null;
|
||||
} else {
|
||||
throw new ClientProtocolException("Unexpected response status: " + status);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
String responseBody = httpclient.execute(httpget, responseHandler);
|
||||
} finally {
|
||||
httpclient.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package test.com.ai.cloud.skywalking.plugin.tomcat78x.servlet;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by xin on 16/7/22.
|
||||
*/
|
||||
@WebServlet(
|
||||
name="myServlet",
|
||||
urlPatterns = {"/hello"}
|
||||
)
|
||||
public class HelloServlet extends HttpServlet{
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
System.out.println("Hello World");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#skyWalking用户ID
|
||||
skywalking.user_id=123
|
||||
#skyWalking应用编码
|
||||
skywalking.application_code=test
|
||||
#skywalking auth的环境变量名字
|
||||
skywalking.auth_system_env_name=SKYWALKING_RUN
|
||||
#skywalking数据编码
|
||||
skywalking.charset=UTF-8
|
||||
skywalking.auth_override=true
|
||||
|
||||
#是否打印数据
|
||||
buriedpoint.printf=true
|
||||
#埋点异常的最大长度
|
||||
buriedpoint.max_exception_stack_length=4000
|
||||
#业务字段的最大长度
|
||||
buriedpoint.businesskey_max_length=300
|
||||
#过滤异常
|
||||
buriedpoint.exclusive_exceptions=java.lang.RuntimeException
|
||||
|
||||
#最大发送者的连接数阀比例
|
||||
sender.connect_percent=100
|
||||
#发送服务端配置
|
||||
sender.servers_addr=127.0.0.1:34000
|
||||
#最大发送的副本数量
|
||||
sender.max_copy_num=2
|
||||
#发送的最大长度
|
||||
sender.max_send_length=20000
|
||||
#当没有Sender时,尝试获取sender的等待周期
|
||||
sender.retry_get_sender_wait_interval=2000
|
||||
|
||||
#最大消费线程数
|
||||
consumer.max_consumer=0
|
||||
#消费者最大等待时间
|
||||
consumer.max_wait_time=5
|
||||
#发送失败等待时间
|
||||
consumer.consumer_fail_retry_wait_interval=50
|
||||
|
||||
#每个Buffer的最大个数
|
||||
buffer.buffer_max_size=18000
|
||||
#Buffer池的最大长度
|
||||
buffer.pool_size=5
|
||||
|
||||
#发送检查线程检查周期
|
||||
senderchecker.check_polling_time=200
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<h2>Hello World</h2>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1 @@
|
|||
com.ai.cloud.skywalking.plugin.tomcat8.define.Tomcat8PluginDefine
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
#skyWalking用户ID
|
||||
skywalking.user_id=123
|
||||
#skyWalking应用编码
|
||||
skywalking.application_code=test
|
||||
#skywalking auth的环境变量名字
|
||||
skywalking.auth_system_env_name=SKYWALKING_RUN
|
||||
#skywalking数据编码
|
||||
skywalking.charset=UTF-8
|
||||
skywalking.auth_override=true
|
||||
|
||||
#是否打印数据
|
||||
buriedpoint.printf=true
|
||||
#埋点异常的最大长度
|
||||
buriedpoint.max_exception_stack_length=4000
|
||||
#业务字段的最大长度
|
||||
buriedpoint.businesskey_max_length=300
|
||||
#过滤异常
|
||||
buriedpoint.exclusive_exceptions=java.lang.RuntimeException
|
||||
|
||||
#最大发送者的连接数阀比例
|
||||
sender.connect_percent=100
|
||||
#发送服务端配置
|
||||
sender.servers_addr=127.0.0.1:34000
|
||||
#最大发送的副本数量
|
||||
sender.max_copy_num=2
|
||||
#发送的最大长度
|
||||
sender.max_send_length=20000
|
||||
#当没有Sender时,尝试获取sender的等待周期
|
||||
sender.retry_get_sender_wait_interval=2000
|
||||
|
||||
#最大消费线程数
|
||||
consumer.max_consumer=0
|
||||
#消费者最大等待时间
|
||||
consumer.max_wait_time=5
|
||||
#发送失败等待时间
|
||||
consumer.consumer_fail_retry_wait_interval=50
|
||||
|
||||
#每个Buffer的最大个数
|
||||
buffer.buffer_max_size=18000
|
||||
#Buffer池的最大长度
|
||||
buffer.pool_size=5
|
||||
|
||||
#发送检查线程检查周期
|
||||
senderchecker.check_polling_time=200
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<html>
|
||||
<body>
|
||||
<h2>Hello World</h2>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -2,7 +2,7 @@ package com.ai.skywalking.testframework.api.config;
|
|||
|
||||
public class Config {
|
||||
|
||||
public static String BUFFER_POOL_CLASS_NAME = "com.ai.cloud.skywalking.buffer.ContextBuffer$BufferPool";
|
||||
public static String BUFFER_POOL_CLASS_NAME = "com.ai.cloud.skywalking.buffer.BufferPool";
|
||||
|
||||
public static String BUFFER_GROUP_FIELD_NAME = "bufferGroups";
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue