#62 provide skywalking-application-toolkit and skywalking-toolkit-activation submodule, and log4j 1.x plugin to output TraceId
This commit is contained in:
parent
c71ffbe0bc
commit
aa6683d2f4
2
pom.xml
2
pom.xml
|
|
@ -13,7 +13,7 @@
|
|||
<module>skywalking-webui</module>
|
||||
<module>skywalking-sniffer</module>
|
||||
<module>skywalking-storage-center</module>
|
||||
<module>skywalking-opentracing-kit</module>
|
||||
<module>skywalking-application-toolkit</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<parent>
|
||||
<artifactId>skywalking</artifactId>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<version>2.0-2016</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>skywalking-application-toolkit</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<compiler.version>1.6</compiler.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>skywalking-toolkit-log4j-1.x</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-toolkit-log4j-1.x</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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-application-toolkit</artifactId>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<version>2.0-2016</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>skywalking-toolkit-log4j-1.x</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>s
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.a.eye.skywalking.plugin.log.log4j.v1.x;
|
||||
|
||||
import org.apache.log4j.helpers.PatternConverter;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/12/7.
|
||||
*/
|
||||
|
||||
public class TraceIdPatternConverter extends PatternConverter {
|
||||
@Override
|
||||
protected String convert(LoggingEvent loggingEvent) {
|
||||
return "TID: N/A";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.a.eye.skywalking.plugin.log.log4j.v1.x;
|
||||
|
||||
|
||||
import org.apache.log4j.PatternLayout;
|
||||
import org.apache.log4j.helpers.PatternParser;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/12/7.
|
||||
*/
|
||||
public class TraceIdPatternLayout extends PatternLayout {
|
||||
@Override
|
||||
protected PatternParser createPatternParser(String pattern) {
|
||||
return new TraceIdPatternParser(pattern);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.a.eye.skywalking.plugin.log.log4j.v1.x;
|
||||
|
||||
import org.apache.log4j.helpers.PatternParser;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/12/7.
|
||||
*/
|
||||
|
||||
public class TraceIdPatternParser extends PatternParser {
|
||||
public TraceIdPatternParser(String pattern) {
|
||||
super(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalizeConverter(char c) {
|
||||
if ('x' == c) {
|
||||
addConverter(new TraceIdPatternConverter());
|
||||
} else {
|
||||
super.finalizeConverter(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<parent>
|
||||
<artifactId>skywalking</artifactId>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<version>2.0-2016</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>skywalking-opentracing-kit</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
</project>
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
<module>skywalking-agent</module>
|
||||
<module>skywalking-api</module>
|
||||
<module>skywalking-sdk-plugin</module>
|
||||
<module>skywalking-toolkit-activation</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- plugin -->
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-jedis-2.x-plugin</artifactId>
|
||||
|
|
@ -56,6 +57,13 @@
|
|||
<artifactId>motan-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- activation -->
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-toolkit-log4j-1.x-activation</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${artifactId}</finalName>
|
||||
|
|
|
|||
|
|
@ -28,11 +28,10 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-api</artifactId>
|
||||
<version>2.0-2016</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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-sniffer</artifactId>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<version>2.0-2016</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>skywalking-toolkit-log4j-1.x-activation</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>skywalking-toolkit-activation</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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-toolkit-activation</artifactId>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<version>2.0-2016</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>skywalking-toolkit-log4j-1.x-activation</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-toolkit-log4j-1.x</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.a.eye.skywalking.toolkit.activation.log4j.v1.x;
|
||||
|
||||
import com.a.eye.skywalking.api.Tracing;
|
||||
import com.a.eye.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/12/7.
|
||||
*/
|
||||
public class PrintTraceIdInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
@Override
|
||||
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
|
||||
return "TID:" + Tracing.getTraceId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.a.eye.skywalking.toolkit.activation.log4j.v1.x;
|
||||
|
||||
import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import com.a.eye.skywalking.plugin.interceptor.MethodMatcher;
|
||||
import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import com.a.eye.skywalking.plugin.interceptor.matcher.SimpleMethodMatcher;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/12/7.
|
||||
*/
|
||||
public class TraceIdPatternConverterActivation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
@Override
|
||||
protected String enhanceClassName() {
|
||||
return "com.a.eye.skywalking.plugin.log.log4j.v1.x.TraceIdPatternConverter";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
|
||||
return new InstanceMethodsInterceptPoint[]{new InstanceMethodsInterceptPoint() {
|
||||
@Override
|
||||
public MethodMatcher[] getMethodsMatchers() {
|
||||
return new MethodMatcher[]{new SimpleMethodMatcher("convert")};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return "com.a.eye.skywalking.toolkit.activation.log4j.v1.x.PrintTraceIdInterceptor";
|
||||
}
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
com.a.eye.skywalking.toolkit.activation.log4j.v1.x.TraceIdPatternConverterActivation
|
||||
Loading…
Reference in New Issue