Unverified Commit c76fb405 authored by 吴晟's avatar 吴晟 Committed by GitHub
Browse files

Set up the bootstrap instrumentation plugin framework (#3152)

* POC: Intercept successfully.

* Refactor codes

* Build the new core

* Setup the new core.

* Push the javassist version to 3.23.2-GA, as it is the last version supports JDK 1.6 compile, according to https://github.com/jboss-javassist/javassist/blob/rel_3_23_2_ga/pom.xml#L149-L160

* Finish the all codes.

* Document updated for bootstrap instrumentation.

* Add a notice to document.

* Remove unexpected file.

* Set javassist version right. Add judge in core interceptors

* Fixe no log bridge implementation
parent c11b9f10
Loading
Loading
Loading
Loading
+36 −11
Original line number Diff line number Diff line
@@ -16,7 +16,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">
<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">
    <modelVersion>4.0.0</modelVersion>

    <parent>
@@ -37,6 +38,10 @@
        <grpc.version>1.14.0</grpc.version>
        <guava.version>20.0</guava.version>
        <bytebuddy.version>1.9.2</bytebuddy.version>
        <!-- 3.21.0-GA is the last version w/ JDK 6 supported -->
        <!-- We can't update this, unless JDK 6 agent is not supported. -->
        <!-- ref discussion, https://github.com/jboss-javassist/javassist/issues/268 -->
        <javaassist.version>3.21.0-GA</javaassist.version>
        <disruptor.version>3.3.6</disruptor.version>
        <wiremock.version>2.6.0</wiremock.version>
        <netty-tcnative-boringssl-static.version>2.0.7.Final</netty-tcnative-boringssl-static.version>
@@ -53,6 +58,8 @@
        <shade.io.netty.target>${shade.package}.${shade.io.netty.source}</shade.io.netty.target>
        <shade.io.opencensus.source>io.opencensus</shade.io.opencensus.source>
        <shade.io.opencensus.target>${shade.package}.${shade.io.opencensus.source}</shade.io.opencensus.target>
        <shade.javaassist.source>javassist</shade.javaassist.source>
        <shade.javaassist.target>${shade.package}.${shade.javaassist.source}</shade.javaassist.target>
        <ststem-rules.version>1.18.0</ststem-rules.version>
    </properties>

@@ -97,6 +104,11 @@
            <artifactId>netty-tcnative-boringssl-static</artifactId>
            <version>${netty-tcnative-boringssl-static.version}</version>
        </dependency>
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>${javaassist.version}</version>
        </dependency>
        <dependency>
            <groupId>net.bytebuddy</groupId>
            <artifactId>byte-buddy-agent</artifactId>
@@ -180,6 +192,10 @@
                                </excludes>
                            </artifactSet>
                            <relocations>
                                <relocation>
                                    <pattern>${shade.javaassist.source}</pattern>
                                    <shadedPattern>${shade.javaassist.target}</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>${shade.com.lmax.disruptor.source}</pattern>
                                    <shadedPattern>${shade.com.lmax.disruptor.target}</shadedPattern>
@@ -211,7 +227,8 @@
                                </filter>
                            </filters>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                            </transformers>
                        </configuration>
                    </execution>
@@ -237,13 +254,21 @@
                        <configuration>
                            <target>
                                <echo message="unjar"/>
                                <unzip src="${project.build.directory}/${project.artifactId}-${project.version}.jar" dest="${project.build.directory}/unpacked/" />
                                <unzip src="${project.build.directory}/${project.artifactId}-${project.version}.jar"
                                       dest="${project.build.directory}/unpacked/"/>
                                <echo message="rename service providers in META-INF/services"/>
                                <move file="${project.build.directory}/unpacked/META-INF/native/libnetty_tcnative_osx_x86_64.jnilib" tofile="${project.build.directory}/unpacked/META-INF/native/liborg_apache_skywalking_apm_dependencies_netty_tcnative_osx_x86_64.jnilib" />
                                <move file="${project.build.directory}/unpacked/META-INF/native/libnetty_tcnative_linux_x86_64.so" tofile="${project.build.directory}/unpacked/META-INF/native/liborg_apache_skywalking_apm_dependencies_netty_tcnative_linux_x86_64.so" />
                                <move file="${project.build.directory}/unpacked/META-INF/native/netty_tcnative_windows_x86_64.dll" tofile="${project.build.directory}/unpacked/META-INF/native/org_apache_skywalking_apm_dependencies_netty_tcnative_windows_x86_64.dll" />
                                <move
                                    file="${project.build.directory}/unpacked/META-INF/native/libnetty_tcnative_osx_x86_64.jnilib"
                                    tofile="${project.build.directory}/unpacked/META-INF/native/liborg_apache_skywalking_apm_dependencies_netty_tcnative_osx_x86_64.jnilib"/>
                                <move
                                    file="${project.build.directory}/unpacked/META-INF/native/libnetty_tcnative_linux_x86_64.so"
                                    tofile="${project.build.directory}/unpacked/META-INF/native/liborg_apache_skywalking_apm_dependencies_netty_tcnative_linux_x86_64.so"/>
                                <move
                                    file="${project.build.directory}/unpacked/META-INF/native/netty_tcnative_windows_x86_64.dll"
                                    tofile="${project.build.directory}/unpacked/META-INF/native/org_apache_skywalking_apm_dependencies_netty_tcnative_windows_x86_64.dll"/>
                                <echo message="jar back"/>
                                <jar destfile="${project.build.directory}/${project.artifactId}-${project.version}.jar" basedir="${project.build.directory}/unpacked" />
                                <jar destfile="${project.build.directory}/${project.artifactId}-${project.version}.jar"
                                     basedir="${project.build.directory}/unpacked"/>
                            </target>
                        </configuration>
                        <goals>
+13 −2
Original line number Diff line number Diff line
@@ -25,9 +25,13 @@ import org.apache.skywalking.apm.agent.core.logging.core.EasyLogResolver;
 * LogManager is the {@link LogResolver} implementation manager. By using {@link LogResolver}, {@link
 * LogManager#getLogger(Class)} returns a {@link ILog} implementation. This module use this class as the main entrance,
 * and block the implementation detail about log-component. In different modules, like server or sniffer, it will use
 * different implementations. <p> If no {@link LogResolver} is registered, return {@link NoopLogger#INSTANCE} to avoid
 * different implementations.
 *
 * <p> If no {@link LogResolver} is registered, return {@link NoopLogger#INSTANCE} to avoid
 * {@link NullPointerException}. If {@link LogManager#setLogResolver(LogResolver)} is called twice, the second will
 * override the first without any warning or exception. <p> Created by xin on 2016/11/10.
 * override the first without any warning or exception.
 *
 * <p> Created by xin on 2016/11/10.
 */
public class LogManager {
    private static LogResolver RESOLVER = new EasyLogResolver();
@@ -42,4 +46,11 @@ public class LogManager {
        }
        return LogManager.RESOLVER.getLogger(clazz);
    }

    public static ILog getLogger(String clazz) {
        if (RESOLVER == null) {
            return NoopLogger.INSTANCE;
        }
        return LogManager.RESOLVER.getLogger(clazz);
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -30,4 +30,10 @@ public interface LogResolver {
     * @return {@link ILog} implementation.
     */
    ILog getLogger(Class<?> clazz);

    /**
     * @param clazz the class is showed in log message.
     * @return {@link ILog} implementation.
     */
    ILog getLogger(String clazz);
}
+4 −0
Original line number Diff line number Diff line
@@ -30,4 +30,8 @@ public class EasyLogResolver implements LogResolver {
    public ILog getLogger(Class<?> clazz) {
        return new EasyLogger(clazz);
    }

    @Override public ILog getLogger(String clazz) {
        return new EasyLogger(clazz);
    }
}
+6 −2
Original line number Diff line number Diff line
@@ -36,9 +36,13 @@ import org.apache.skywalking.apm.util.StringUtil;
 */
public class EasyLogger implements ILog {

    private Class targetClass;
    private String targetClass;

    public EasyLogger(Class targetClass) {
        this.targetClass = targetClass.getSimpleName();
    }

    public EasyLogger(String targetClass) {
        this.targetClass = targetClass;
    }

@@ -68,7 +72,7 @@ public class EasyLogger implements ILog {
        return StringUtil.join(' ', level.name(),
            new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date()),
            Thread.currentThread().getName(),
            targetClass.getSimpleName(),
            targetClass,
            ": ",
            message,
            t == null ? "" : format(t)
Loading