Recover logging-api/logging-log4j2 modules. Adjust codes for new modules.
This commit is contained in:
parent
2fb18ebc4e
commit
738d156495
|
|
@ -24,36 +24,6 @@
|
|||
<artifactId>akka-cluster_2.11</artifactId>
|
||||
<version>${akka.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.typesafe.akka</groupId>
|
||||
<artifactId>akka-cluster-metrics_2.11</artifactId>
|
||||
<version>${akka.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.typesafe.akka</groupId>
|
||||
<artifactId>akka-cluster-tools_2.11</artifactId>
|
||||
<version>${akka.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.typesafe.akka</groupId>
|
||||
<artifactId>akka-persistence_2.11</artifactId>
|
||||
<version>${akka.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.iq80.leveldb</groupId>
|
||||
<artifactId>leveldb</artifactId>
|
||||
<version>0.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.typesafe.akka</groupId>
|
||||
<artifactId>akka-testkit_2.11</artifactId>
|
||||
|
|
@ -62,9 +32,8 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-sniffer-mock</artifactId>
|
||||
<artifactId>skywalking-logging-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -17,19 +17,14 @@
|
|||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<version>1</version>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.lmax</groupId>
|
||||
<artifactId>disruptor</artifactId>
|
||||
<version>3.3.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@ import akka.actor.ActorRef;
|
|||
import com.a.eye.skywalking.collector.actor.selector.WorkerSelector;
|
||||
import com.a.eye.skywalking.collector.cluster.WorkersRefCenter;
|
||||
import com.a.eye.skywalking.collector.queue.MessageHolder;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import com.lmax.disruptor.EventHandler;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -15,7 +14,7 @@ import java.util.List;
|
|||
*/
|
||||
public abstract class AbstractMember implements EventHandler<MessageHolder> {
|
||||
|
||||
private Logger logger = LogManager.getFormatterLogger(AbstractMember.class);
|
||||
private ILog logger = LogManager.getLogger(AbstractMember.class);
|
||||
|
||||
private ActorRef actorRef;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@ import com.a.eye.skywalking.collector.actor.selector.WorkerSelector;
|
|||
import com.a.eye.skywalking.collector.cluster.WorkerListenerMessage;
|
||||
import com.a.eye.skywalking.collector.cluster.WorkersListener;
|
||||
import com.a.eye.skywalking.collector.cluster.WorkersRefCenter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -40,7 +39,7 @@ import java.util.List;
|
|||
*/
|
||||
public abstract class AbstractWorker extends UntypedActor {
|
||||
|
||||
private Logger logger = LogManager.getFormatterLogger(AbstractWorker.class);
|
||||
private ILog logger = LogManager.getLogger(AbstractWorker.class);
|
||||
|
||||
private Cluster cluster = Cluster.get(getContext().system());
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package com.a.eye.skywalking.collector.actor;
|
|||
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.actor.Props;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
|
||||
/**
|
||||
* The <code>AbstractWorkerProvider</code> should be implemented by any class whose
|
||||
|
|
@ -28,8 +28,7 @@ import org.apache.logging.log4j.Logger;
|
|||
* <p>
|
||||
*/
|
||||
public abstract class AbstractWorkerProvider {
|
||||
|
||||
private Logger logger = LogManager.getFormatterLogger(AbstractWorkerProvider.class);
|
||||
private ILog logger = LogManager.getLogger(AbstractWorkerProvider.class);
|
||||
|
||||
public abstract Class workerClass();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package com.a.eye.skywalking.collector.actor;
|
|||
|
||||
import akka.actor.ActorPath;
|
||||
import akka.actor.ActorRef;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
|
||||
/**
|
||||
* The Worker reference
|
||||
|
|
@ -11,7 +11,7 @@ import org.apache.logging.log4j.Logger;
|
|||
* @author pengys5
|
||||
*/
|
||||
public class WorkerRef {
|
||||
private Logger logger = LogManager.getFormatterLogger(WorkerRef.class);
|
||||
private ILog logger = LogManager.getLogger(WorkerRef.class);
|
||||
|
||||
final ActorRef actorRef;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package com.a.eye.skywalking.collector.actor;
|
|||
import akka.actor.ActorSystem;
|
||||
import akka.actor.Props;
|
||||
import com.a.eye.skywalking.collector.cluster.WorkersListener;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ import java.util.ServiceLoader;
|
|||
public enum WorkersCreator {
|
||||
INSTANCE;
|
||||
|
||||
private Logger logger = LogManager.getFormatterLogger(WorkersCreator.class);
|
||||
private ILog logger = LogManager.getLogger(WorkersCreator.class);
|
||||
|
||||
/**
|
||||
* create worker to use Java Spi.
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@ package com.a.eye.skywalking.collector.cluster;
|
|||
|
||||
import com.a.eye.skywalking.api.util.ConfigInitializer;
|
||||
import com.a.eye.skywalking.api.util.StringUtil;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
|
|
@ -21,7 +20,7 @@ import java.util.Properties;
|
|||
*/
|
||||
public class ClusterConfigInitializer {
|
||||
|
||||
private static Logger logger = LogManager.getFormatterLogger(ClusterConfigInitializer.class);
|
||||
private static ILog logger = LogManager.getLogger(ClusterConfigInitializer.class);
|
||||
|
||||
public static final String ConfigFileName = "collector.config";
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import akka.actor.Terminated;
|
|||
import akka.actor.UntypedActor;
|
||||
import akka.cluster.Cluster;
|
||||
import akka.cluster.ClusterEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
|
||||
/**
|
||||
* <code>WorkersListener</code> listening the register message from workers
|
||||
|
|
@ -22,7 +22,7 @@ import org.apache.logging.log4j.Logger;
|
|||
*/
|
||||
public class WorkersListener extends UntypedActor {
|
||||
|
||||
private Logger logger = LogManager.getFormatterLogger(WorkersListener.class);
|
||||
private ILog logger = LogManager.getLogger(WorkersListener.class);
|
||||
|
||||
public static final String WorkName = "WorkersListener";
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,16 @@
|
|||
<artifactId>skywalking-collector-cluster</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-trace</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-logging-log4j2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
|
|
@ -35,4 +45,4 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.a.eye.skywalking.collector.cluster.ClusterConfig;
|
|||
import com.a.eye.skywalking.collector.cluster.ClusterConfigInitializer;
|
||||
import com.a.eye.skywalking.collector.cluster.NoAvailableWorkerException;
|
||||
import com.a.eye.skywalking.collector.worker.storage.EsClient;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import com.a.eye.skywalking.logging.log4j2.Log4j2Resolver;
|
||||
import com.typesafe.config.Config;
|
||||
import com.typesafe.config.ConfigFactory;
|
||||
|
||||
|
|
@ -17,6 +19,8 @@ import java.net.UnknownHostException;
|
|||
public class CollectorBootStartUp {
|
||||
|
||||
public static void main(String[] args) throws NoAvailableWorkerException, InterruptedException, UnknownHostException {
|
||||
LogManager.setLogResolver(new Log4j2Resolver());
|
||||
|
||||
ClusterConfigInitializer.initialize("collector.config");
|
||||
|
||||
final Config config = ConfigFactory.parseString("akka.remote.netty.tcp.hostname=" + ClusterConfig.Cluster.Current.hostname).
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
package com.a.eye.skywalking.collector.worker;
|
||||
|
||||
import akka.serialization.JSerializer;
|
||||
import com.a.eye.skywalking.trace.TraceSegment;
|
||||
import com.a.eye.skywalking.trace.proto.SegmentMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
|
|
@ -23,14 +20,12 @@ public class JsonSerializer extends JSerializer {
|
|||
|
||||
@Override
|
||||
public byte[] toBinary(Object o) {
|
||||
// System.out.println("Json toBinary");
|
||||
JsonObject jsonObject = (JsonObject) o;
|
||||
return jsonObject.toString().getBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object fromBinaryJava(byte[] bytes, Class<?> manifest) {
|
||||
// System.out.println("Json fromBinaryJava");
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(new String(bytes), JsonObject.class);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
<modules>
|
||||
<module>skywalking-trace</module>
|
||||
<module>skywalking-util</module>
|
||||
<module>skywalking-logging-api</module>
|
||||
<module>skywalking-logging-log4j2</module>
|
||||
</modules>
|
||||
|
||||
<name>skywalking-commons</name>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
<?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-commons</artifactId>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<version>3.0-2017</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>skywalking-logging-api</artifactId>
|
||||
|
||||
|
||||
</project>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.a.eye.skywalking.api.logging;
|
||||
package com.a.eye.skywalking.logging;
|
||||
|
||||
/**
|
||||
* The Log interface.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.a.eye.skywalking.api.logging;
|
||||
package com.a.eye.skywalking.logging;
|
||||
|
||||
/**
|
||||
* LogManager is the {@link LogResolver} implementation manager.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.a.eye.skywalking.api.logging;
|
||||
package com.a.eye.skywalking.logging;
|
||||
|
||||
/**
|
||||
* {@link LogResolver} just do only one thing: return the {@link ILog} implementation.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.a.eye.skywalking.api.logging;
|
||||
package com.a.eye.skywalking.logging;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.a.eye.skywalking.api.logging;
|
||||
package com.a.eye.skywalking.logging;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
|
@ -7,21 +7,9 @@ import org.junit.Test;
|
|||
import org.powermock.api.support.membermodification.MemberModifier;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/27.
|
||||
* @author wusheng
|
||||
*/
|
||||
public class LogManagerTest {
|
||||
@Test
|
||||
public void testGetLogger() {
|
||||
final TestLogger logger = new TestLogger();
|
||||
LogManager.setLogResolver(new LogResolver() {
|
||||
@Override
|
||||
public ILog getLogger(Class<?> clazz) {
|
||||
return logger;
|
||||
}
|
||||
});
|
||||
|
||||
Assert.assertEquals(logger, LogManager.getLogger(LogManagerTest.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNoopLogger(){
|
||||
|
|
@ -86,5 +74,5 @@ public class LogManagerTest {
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
package com.a.eye.skywalking.api.logging;
|
||||
|
||||
package com.a.eye.skywalking.logging;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.a.eye.skywalking.api.logging.NoopLogger.INSTANCE;
|
||||
import static com.a.eye.skywalking.logging.NoopLogger.INSTANCE;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/27.
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?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-commons</artifactId>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<version>3.0-2017</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>skywalking-logging-log4j2</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-logging-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
package com.a.eye.skywalking.logging.log4j2;
|
||||
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class Log4j2Logger implements ILog {
|
||||
private Logger delegateLogger;
|
||||
|
||||
Log4j2Logger(Class<?> targetClass){
|
||||
delegateLogger = LogManager.getFormatterLogger(targetClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String format) {
|
||||
delegateLogger.info(format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String format, Object... arguments) {
|
||||
delegateLogger.info(format, arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String format, Object... arguments) {
|
||||
delegateLogger.warn(format, arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String format, Throwable e) {
|
||||
delegateLogger.error(format, e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Throwable e, String format, Object... arguments) {
|
||||
delegateLogger.error(format, e, arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnable() {
|
||||
return delegateLogger.isDebugEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInfoEnable() {
|
||||
return delegateLogger.isInfoEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWarnEnable() {
|
||||
return delegateLogger.isWarnEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isErrorEnable() {
|
||||
return delegateLogger.isErrorEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String format) {
|
||||
delegateLogger.debug(format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String format, Object... arguments) {
|
||||
delegateLogger.debug(format, arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String format) {
|
||||
delegateLogger.error(format);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.a.eye.skywalking.logging.log4j2;
|
||||
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogResolver;
|
||||
|
||||
/**
|
||||
* The <code>LogResolver</code> is an implementation of {@link LogResolver},
|
||||
*
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class Log4j2Resolver implements LogResolver {
|
||||
@Override
|
||||
public ILog getLogger(Class<?> clazz) {
|
||||
return new Log4j2Logger(clazz);
|
||||
}
|
||||
}
|
||||
|
|
@ -45,6 +45,30 @@
|
|||
<pattern>${shade.com.lmax.disruptor.source}</pattern>
|
||||
<shadedPattern>${shade.com.lmax.disruptor.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.akka.source}</pattern>
|
||||
<shadedPattern>${shade.akka.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.com.google.source}</pattern>
|
||||
<shadedPattern>${shade.com.google.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.all.org.source}</pattern>
|
||||
<shadedPattern>${shade.all.org.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.scala.source}</pattern>
|
||||
<shadedPattern>${shade.scala.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.io.aeron.source}</pattern>
|
||||
<shadedPattern>${shade.io.aeron.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.com.typesafe.source}</pattern>
|
||||
<shadedPattern>${shade.com.typesafe.target}</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
@ -112,13 +136,25 @@
|
|||
</repository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<shade.net.bytebuddy.target>${shade.package}.${shade.net.bytebuddy.source}</shade.net.bytebuddy.target>
|
||||
<shade.package>com.a.eye.skywalking.api.dependencies</shade.package>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<shade.com.lmax.disruptor.source>com.lmax.disruptor</shade.com.lmax.disruptor.source>
|
||||
<shade.com.typesafe.target>${shade.package}.${shade.com.typesafe.source}</shade.com.typesafe.target>
|
||||
<shade.com.lmax.disruptor.target>${shade.package}.${shade.com.lmax.disruptor.source}</shade.com.lmax.disruptor.target>
|
||||
<shade.net.bytebuddy.source>net.bytebuddy</shade.net.bytebuddy.source>
|
||||
<shade.akka.target>${shade.package}.${shade.akka.source}</shade.akka.target>
|
||||
<shade.io.aeron.target>${shade.package}.${shade.io.aeron.source}</shade.io.aeron.target>
|
||||
<shade.all.org.target>${shade.package}.${shade.all.org.source}</shade.all.org.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<shade.scala.source>scala</shade.scala.source>
|
||||
<shade.net.bytebuddy.target>${shade.package}.${shade.net.bytebuddy.source}</shade.net.bytebuddy.target>
|
||||
<shade.package>com.a.eye.skywalking.dependencies</shade.package>
|
||||
<shade.com.google.source>com.google</shade.com.google.source>
|
||||
<shade.scala.target>${shade.package}.${shade.scala.source}</shade.scala.target>
|
||||
<shade.com.typesafe.source>com.typesafe</shade.com.typesafe.source>
|
||||
<shade.com.lmax.disruptor.source>com.lmax.disruptor</shade.com.lmax.disruptor.source>
|
||||
<shade.akka.source>akka</shade.akka.source>
|
||||
<premain.class>com.a.eye.skywalking.agent.SkyWalkingAgent</premain.class>
|
||||
<shade.io.aeron.source>io.aeron</shade.io.aeron.source>
|
||||
<shade.all.org.source>org</shade.all.org.source>
|
||||
<shade.com.google.target>${shade.package}.${shade.com.google.source}</shade.com.google.target>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
|
|
|
|||
|
|
@ -16,13 +16,24 @@
|
|||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<shade.package>com.a.eye.skywalking.api.dependencies</shade.package>
|
||||
<shade.package>com.a.eye.skywalking.dependencies</shade.package>
|
||||
<premain.class>com.a.eye.skywalking.agent.SkyWalkingAgent</premain.class>
|
||||
<shade.net.bytebuddy.source>net.bytebuddy</shade.net.bytebuddy.source>
|
||||
<shade.net.bytebuddy.target>${shade.package}.${shade.net.bytebuddy.source}</shade.net.bytebuddy.target>
|
||||
<!-- queue -->
|
||||
<shade.com.lmax.disruptor.source>com.lmax.disruptor</shade.com.lmax.disruptor.source>
|
||||
<shade.com.lmax.disruptor.target>${shade.package}.${shade.com.lmax.disruptor.source}</shade.com.lmax.disruptor.target>
|
||||
<shade.akka.source>akka</shade.akka.source>
|
||||
<shade.akka.target>${shade.package}.${shade.akka.source}</shade.akka.target>
|
||||
<shade.scala.source>scala</shade.scala.source>
|
||||
<shade.scala.target>${shade.package}.${shade.scala.source}</shade.scala.target>
|
||||
<shade.all.org.source>org</shade.all.org.source>
|
||||
<shade.all.org.target>${shade.package}.${shade.all.org.source}</shade.all.org.target>
|
||||
<shade.com.google.source>com.google</shade.com.google.source>
|
||||
<shade.com.google.target>${shade.package}.${shade.com.google.source}</shade.com.google.target>
|
||||
<shade.io.aeron.source>io.aeron</shade.io.aeron.source>
|
||||
<shade.io.aeron.target>${shade.package}.${shade.io.aeron.source}</shade.io.aeron.target>
|
||||
<shade.com.typesafe.source>com.typesafe</shade.com.typesafe.source>
|
||||
<shade.com.typesafe.target>${shade.package}.${shade.com.typesafe.source}</shade.com.typesafe.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
@ -127,6 +138,30 @@
|
|||
<pattern>${shade.com.lmax.disruptor.source}</pattern>
|
||||
<shadedPattern>${shade.com.lmax.disruptor.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.akka.source}</pattern>
|
||||
<shadedPattern>${shade.akka.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.com.google.source}</pattern>
|
||||
<shadedPattern>${shade.com.google.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.all.org.source}</pattern>
|
||||
<shadedPattern>${shade.all.org.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.scala.source}</pattern>
|
||||
<shadedPattern>${shade.scala.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.io.aeron.source}</pattern>
|
||||
<shadedPattern>${shade.io.aeron.target}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>${shade.com.typesafe.source}</pattern>
|
||||
<shadedPattern>${shade.com.typesafe.target}</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
package com.a.eye.skywalking.agent;
|
||||
|
||||
import com.a.eye.skywalking.agent.junction.SkyWalkingEnhanceMatcher;
|
||||
import com.a.eye.skywalking.api.boot.ServiceStarter;
|
||||
import com.a.eye.skywalking.api.conf.Config;
|
||||
import com.a.eye.skywalking.api.conf.SnifferConfigInitializer;
|
||||
import com.a.eye.skywalking.api.logging.EasyLogResolver;
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.api.plugin.AbstractClassEnhancePluginDefine;
|
||||
import com.a.eye.skywalking.api.plugin.PluginBootstrap;
|
||||
import com.a.eye.skywalking.api.plugin.PluginFinder;
|
||||
import com.a.eye.skywalking.api.plugin.PluginException;
|
||||
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import net.bytebuddy.agent.builder.AgentBuilder;
|
||||
import net.bytebuddy.description.NamedElement;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
|
|
@ -53,6 +54,8 @@ public class SkyWalkingAgent {
|
|||
|
||||
final PluginFinder pluginFinder = new PluginFinder(new PluginBootstrap().loadPlugins());
|
||||
|
||||
ServiceStarter.INSTANCE.boot();
|
||||
|
||||
new AgentBuilder.Default().type(enhanceClassMatcher(pluginFinder).and(not(isInterface()))).transform(new AgentBuilder.Transformer() {
|
||||
public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassLoader classLoader) {
|
||||
AbstractClassEnhancePluginDefine pluginDefine = pluginFinder.find(typeDescription.getTypeName());
|
||||
|
|
|
|||
|
|
@ -20,16 +20,26 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
<version>1.5.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-trace</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-logging-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-collector-cluster</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
<version>1.5.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.lmax</groupId>
|
||||
<artifactId>disruptor</artifactId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.a.eye.skywalking.api.boot;
|
||||
|
||||
/**
|
||||
* The <code>BootService</code> is an interface to all services, which need to boot when plugin mechanism begins to
|
||||
* work.
|
||||
* {@link #bootUp()} will be called when <code>BootService</code> start up.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public interface BootService {
|
||||
void bootUp();
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.a.eye.skywalking.api.boot;
|
||||
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import java.util.Iterator;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* The <code>ServiceStarter</code> bases on {@link ServiceLoader},
|
||||
* load all {@link BootService} implementations.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public enum ServiceStarter {
|
||||
INSTANCE;
|
||||
|
||||
private static ILog logger = LogManager.getLogger(StatusBootService.class);
|
||||
private volatile boolean isStarted = false;
|
||||
|
||||
public void boot() {
|
||||
while (!isStarted) {
|
||||
try {
|
||||
Iterator<BootService> serviceIterator = load().iterator();
|
||||
while (serviceIterator.hasNext()) {
|
||||
BootService bootService = serviceIterator.next();
|
||||
try {
|
||||
bootService.bootUp();
|
||||
} catch (Exception e) {
|
||||
logger.error(e, "ServiceStarter try to start [{}] fail.", bootService.getClass().getName());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
isStarted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ServiceLoader<BootService> load() {
|
||||
return ServiceLoader.load(BootService.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.a.eye.skywalking.api.boot;
|
||||
|
||||
/**
|
||||
* The <code>StatusBootService</code> is an abstract implementations of {@link BootService},
|
||||
* it extends {@link BootService}'s ability like this:
|
||||
*
|
||||
* If an implementation extends <code>StatusBootService</code>, it can know whether this service starts up successfully or not.
|
||||
* It's based on {@link #bootUp()} function finished with or without an exception. if no exception, means start up successfully.
|
||||
*
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public abstract class StatusBootService implements BootService {
|
||||
private volatile boolean started = false;
|
||||
|
||||
protected boolean isStarted(){
|
||||
return this.started;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void bootUp(){
|
||||
try {
|
||||
bootUpWithStatus();
|
||||
started = true;
|
||||
} catch (Throwable e) {
|
||||
started = false;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void bootUpWithStatus();
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.a.eye.skywalking.api.conf;
|
||||
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import com.a.eye.skywalking.api.util.ConfigInitializer;
|
||||
import com.a.eye.skywalking.api.util.StringUtil;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.api.context;
|
||||
|
||||
import com.a.eye.skywalking.api.boot.BootService;
|
||||
import com.a.eye.skywalking.api.queue.TraceSegmentProcessQueue;
|
||||
import com.a.eye.skywalking.trace.Span;
|
||||
import com.a.eye.skywalking.trace.TraceSegment;
|
||||
|
|
@ -16,21 +17,10 @@ import com.a.eye.skywalking.trace.TraceSegment;
|
|||
*
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public enum ContextManager implements TracerContextListener {
|
||||
INSTANCE {
|
||||
@Override public void afterFinished(TraceSegment traceSegment) {
|
||||
CONTEXT.remove();
|
||||
}
|
||||
};
|
||||
|
||||
ContextManager() {
|
||||
TracerContext.ListenerManager.add(this);
|
||||
TraceSegmentProcessQueue.INSTANCE.start();
|
||||
}
|
||||
|
||||
public class ContextManager implements TracerContextListener, BootService {
|
||||
private static ThreadLocal<TracerContext> CONTEXT = new ThreadLocal<>();
|
||||
|
||||
private TracerContext get() {
|
||||
private static TracerContext get() {
|
||||
TracerContext segment = CONTEXT.get();
|
||||
if (segment == null) {
|
||||
segment = new TracerContext();
|
||||
|
|
@ -42,28 +32,28 @@ public enum ContextManager implements TracerContextListener {
|
|||
/**
|
||||
* @see {@link TracerContext#inject(ContextCarrier)}
|
||||
*/
|
||||
public void inject(ContextCarrier carrier) {
|
||||
public static void inject(ContextCarrier carrier) {
|
||||
get().inject(carrier);
|
||||
}
|
||||
|
||||
/**
|
||||
*@see {@link TracerContext#extract(ContextCarrier)}
|
||||
*/
|
||||
public void extract(ContextCarrier carrier) {
|
||||
public static void extract(ContextCarrier carrier) {
|
||||
get().extract(carrier);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link TracerContext#extract(ContextCarrier)}
|
||||
*/
|
||||
public void multiExtract(ContextCarrier carrier){
|
||||
public static void multiExtract(ContextCarrier carrier){
|
||||
get().extract(carrier);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link TraceSegment#traceSegmentId} if exist. Otherwise, "N/A".
|
||||
*/
|
||||
public String getTraceSegmentId(){
|
||||
public static String getTraceSegmentId(){
|
||||
TracerContext segment = CONTEXT.get();
|
||||
if(segment == null){
|
||||
return "N/A";
|
||||
|
|
@ -72,27 +62,37 @@ public enum ContextManager implements TracerContextListener {
|
|||
}
|
||||
}
|
||||
|
||||
public Span createSpan(String operationName) {
|
||||
public static Span createSpan(String operationName) {
|
||||
return get().createSpan(operationName);
|
||||
}
|
||||
|
||||
public Span createSpan(String operationName, long startTime) {
|
||||
return get().createSpan(operationName);
|
||||
public static Span createSpan(String operationName, long startTime) {
|
||||
return get().createSpan(operationName, startTime);
|
||||
}
|
||||
|
||||
public Span activeSpan() {
|
||||
public static Span activeSpan() {
|
||||
return get().activeSpan();
|
||||
}
|
||||
|
||||
public void stopSpan(Span span) {
|
||||
public static void stopSpan(Span span) {
|
||||
get().stopSpan(span);
|
||||
}
|
||||
|
||||
public void stopSpan(Long endTime) {
|
||||
public static void stopSpan(Long endTime) {
|
||||
get().stopSpan(activeSpan(), endTime);
|
||||
}
|
||||
|
||||
public void stopSpan() {
|
||||
public static void stopSpan() {
|
||||
stopSpan(activeSpan());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bootUp(){
|
||||
TracerContext.ListenerManager.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterFinished(TraceSegment traceSegment) {
|
||||
CONTEXT.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.a.eye.skywalking.api.logging;
|
||||
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogResolver;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/11/26.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.a.eye.skywalking.api.logging;
|
||||
|
||||
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.a.eye.skywalking.api.plugin;
|
||||
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassEnhancePluginDefine;
|
||||
import com.a.eye.skywalking.api.util.StringUtil;
|
||||
import net.bytebuddy.dynamic.DynamicType;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package com.a.eye.skywalking.api.plugin;
|
||||
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
|
||||
import net.bytebuddy.pool.TypePool;
|
||||
|
||||
import java.net.URL;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.a.eye.skywalking.api.plugin;
|
||||
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.a.eye.skywalking.api.plugin;
|
||||
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import net.bytebuddy.ByteBuddy;
|
||||
import net.bytebuddy.dynamic.ClassFileLocator;
|
||||
import net.bytebuddy.dynamic.DynamicType;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
|
||||
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.loader.InterceptorInstanceLoader;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import net.bytebuddy.implementation.bind.annotation.AllArguments;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
|
||||
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import com.a.eye.skywalking.api.plugin.AbstractClassEnhancePluginDefine;
|
||||
import com.a.eye.skywalking.api.plugin.PluginException;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
|
||||
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.loader.InterceptorInstanceLoader;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import net.bytebuddy.implementation.bind.annotation.*;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
|
||||
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.loader.InterceptorInstanceLoader;
|
||||
import net.bytebuddy.implementation.bind.annotation.AllArguments;
|
||||
import net.bytebuddy.implementation.bind.annotation.Origin;
|
||||
import net.bytebuddy.implementation.bind.annotation.RuntimeType;
|
||||
import net.bytebuddy.implementation.bind.annotation.SuperCall;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.Callable;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package com.a.eye.skywalking.api.plugin.interceptor.enhance;
|
||||
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import net.bytebuddy.implementation.bind.annotation.AllArguments;
|
||||
import net.bytebuddy.implementation.bind.annotation.FieldProxy;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package com.a.eye.skywalking.api.plugin.interceptor.loader;
|
||||
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.api.queue;
|
||||
|
||||
import com.a.eye.skywalking.api.boot.StatusBootService;
|
||||
import com.a.eye.skywalking.api.conf.Config;
|
||||
import com.a.eye.skywalking.api.context.TracerContext;
|
||||
import com.a.eye.skywalking.api.context.TracerContextListener;
|
||||
|
|
@ -15,9 +16,24 @@ import com.lmax.disruptor.util.DaemonThreadFactory;
|
|||
*
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public enum TraceSegmentProcessQueue implements TracerContextListener {
|
||||
INSTANCE {
|
||||
@Override public void afterFinished(TraceSegment traceSegment) {
|
||||
public class TraceSegmentProcessQueue extends StatusBootService implements TracerContextListener {
|
||||
private Disruptor<TraceSegmentHolder> disruptor;
|
||||
private RingBuffer<TraceSegmentHolder> buffer;
|
||||
|
||||
public TraceSegmentProcessQueue() {
|
||||
disruptor = new Disruptor<>(TraceSegmentHolder.Factory.INSTANCE, Config.Disruptor.BUFFER_SIZE, DaemonThreadFactory.INSTANCE);
|
||||
buffer = disruptor.getRingBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bootUpWithStatus() {
|
||||
TracerContext.ListenerManager.add(this);
|
||||
disruptor.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterFinished(TraceSegment traceSegment) {
|
||||
if(isStarted()) {
|
||||
long sequence = this.buffer.next(); // Grab the next sequence
|
||||
try {
|
||||
TraceSegmentHolder data = this.buffer.get(sequence);
|
||||
|
|
@ -26,19 +42,5 @@ public enum TraceSegmentProcessQueue implements TracerContextListener {
|
|||
this.buffer.publish(sequence);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private Disruptor<TraceSegmentHolder> disruptor;
|
||||
RingBuffer<TraceSegmentHolder> buffer;
|
||||
|
||||
TraceSegmentProcessQueue() {
|
||||
disruptor = new Disruptor<>(TraceSegmentHolder.Factory.INSTANCE, Config.Disruptor.BUFFER_SIZE, DaemonThreadFactory.INSTANCE);
|
||||
buffer = disruptor.getRingBuffer();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
TracerContext.ListenerManager.add(this);
|
||||
disruptor.start();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
com.a.eye.skywalking.api.queue.TraceSegmentProcessQueue
|
||||
com.a.eye.skywalking.api.context.ContextManager
|
||||
|
|
@ -13,13 +13,13 @@ import org.junit.Test;
|
|||
public class ContextManagerTestCase {
|
||||
@Test
|
||||
public void testDelegateToTracerContext(){
|
||||
Span span = ContextManager.INSTANCE.createSpan("serviceA");
|
||||
Span span = ContextManager.createSpan("serviceA");
|
||||
Tags.COMPONENT.set(span, "test");
|
||||
|
||||
Assert.assertEquals(span, ContextManager.INSTANCE.activeSpan());
|
||||
Assert.assertEquals(span, ContextManager.activeSpan());
|
||||
|
||||
TracerContext.ListenerManager.add(TestTracerContextListener.INSTANCE);
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
|
||||
TraceSegment segment = TestTracerContextListener.INSTANCE.finishedSegmentCarrier[0];
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
boolean isConsumer = rpcContext.isConsumerSide();
|
||||
URL requestURL = invoker.getUrl();
|
||||
|
||||
Span span = ContextManager.INSTANCE.createSpan(generateOperationName(requestURL, invocation));
|
||||
Span span = ContextManager.createSpan(generateOperationName(requestURL, invocation));
|
||||
Tags.URL.set(span, generateRequestURL(requestURL, invocation));
|
||||
Tags.COMPONENT.set(span, DUBBO_COMPONENT);
|
||||
Tags.SPAN_LAYER.asRPCFramework(span);
|
||||
|
|
@ -61,7 +61,7 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
Tags.PEER_PORT.set(span, requestURL.getPort());
|
||||
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_CLIENT);
|
||||
ContextCarrier contextCarrier = new ContextCarrier();
|
||||
ContextManager.INSTANCE.inject(contextCarrier);
|
||||
ContextManager.inject(contextCarrier);
|
||||
if (!BugFixActive.isActive()) {
|
||||
//invocation.getAttachments().put("contextData", contextDataStr);
|
||||
//@see https://github.com/alibaba/dubbo/blob/dubbo-2.5.3/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcInvocation.java#L154-L161
|
||||
|
|
@ -80,7 +80,7 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
}
|
||||
|
||||
if (contextCarrier != null) {
|
||||
ContextManager.INSTANCE.extract(contextCarrier);
|
||||
ContextManager.extract(contextCarrier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
dealException(result.getException());
|
||||
}
|
||||
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ public class DubboInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
* Log the throwable, which occurs in Dubbo RPC service.
|
||||
*/
|
||||
private void dealException(Throwable throwable) {
|
||||
Span span = ContextManager.INSTANCE.activeSpan();
|
||||
Span span = ContextManager.activeSpan();
|
||||
Tags.ERROR.set(span, true);
|
||||
span.log(throwable);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.plugin.dubbo;
|
||||
|
||||
import com.a.eye.skywalking.api.boot.ServiceStarter;
|
||||
import com.a.eye.skywalking.api.context.TracerContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
|
|
@ -59,6 +60,8 @@ public class DubboInterceptorTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ServiceStarter.INSTANCE.boot();
|
||||
|
||||
dubboInterceptor = new DubboInterceptor();
|
||||
testParam = new RequestParamForTestBelow283();
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
|
|
@ -226,4 +229,4 @@ public class DubboInterceptorTest {
|
|||
TracerContext.ListenerManager.remove(mockTracerContextListener);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-api</artifactId>
|
||||
<version>3.0-2017</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
|
|||
Tags.SPAN_LAYER.asHttp(span);
|
||||
|
||||
ContextCarrier contextCarrier = new ContextCarrier();
|
||||
ContextManager.INSTANCE.inject(contextCarrier);
|
||||
ContextManager.inject(contextCarrier);
|
||||
httpRequest.setHeader(HEADER_NAME_OF_CONTEXT_DATA, contextCarrier.serialize());
|
||||
}
|
||||
|
||||
|
|
@ -68,9 +68,9 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
|
|||
Span span;
|
||||
try {
|
||||
URL url = new URL(httpRequest.getRequestLine().getUri());
|
||||
span = ContextManager.INSTANCE.createSpan(url.getPath());
|
||||
span = ContextManager.createSpan(url.getPath());
|
||||
} catch (MalformedURLException e) {
|
||||
span = ContextManager.INSTANCE.createSpan(httpRequest.getRequestLine().getUri());
|
||||
span = ContextManager.createSpan(httpRequest.getRequestLine().getUri());
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
|
@ -85,20 +85,20 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
|
|||
|
||||
HttpResponse response = (HttpResponse) ret;
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
Span span = ContextManager.INSTANCE.activeSpan();
|
||||
Span span = ContextManager.activeSpan();
|
||||
if (statusCode != 200) {
|
||||
Tags.ERROR.set(span, true);
|
||||
}
|
||||
|
||||
Tags.STATUS_CODE.set(span, statusCode);
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
|
||||
Tags.ERROR.set(ContextManager.INSTANCE.activeSpan(), true);
|
||||
ContextManager.INSTANCE.activeSpan().log(t);
|
||||
Tags.ERROR.set(ContextManager.activeSpan(), true);
|
||||
ContextManager.activeSpan().log(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.plugin.httpClient.v4;
|
||||
|
||||
import com.a.eye.skywalking.api.boot.ServiceStarter;
|
||||
import com.a.eye.skywalking.api.context.TracerContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
|
|
@ -56,6 +57,8 @@ public class HttpClientExecuteInterceptorTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
|
||||
ServiceStarter.INSTANCE.boot();
|
||||
httpClientExecuteInterceptor = new HttpClientExecuteInterceptor();
|
||||
|
||||
PowerMockito.mock(HttpHost.class);
|
||||
|
|
@ -163,4 +166,4 @@ public class HttpClientExecuteInterceptorTest {
|
|||
TracerContext.ListenerManager.remove(mockTracerContextListener);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class CallableStatementTracing {
|
|||
ConnectionInfo connectInfo, String method, String sql, Executable<R> exec)
|
||||
throws SQLException {
|
||||
try {
|
||||
Span span = ContextManager.INSTANCE.createSpan("JDBC/CallableStatement/" + method);
|
||||
Span span = ContextManager.createSpan("JDBC/CallableStatement/" + method);
|
||||
Tags.DB_TYPE.set(span, "sql");
|
||||
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
|
||||
Tags.DB_STATEMENT.set(span, sql);
|
||||
|
|
@ -36,12 +36,12 @@ public class CallableStatementTracing {
|
|||
}
|
||||
return exec.exe(realStatement, sql);
|
||||
} catch (SQLException e) {
|
||||
Span span = ContextManager.INSTANCE.activeSpan();
|
||||
Span span = ContextManager.activeSpan();
|
||||
Tags.ERROR.set(span, true);
|
||||
span.log(e);
|
||||
throw e;
|
||||
} finally {
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class ConnectionTracing {
|
|||
ConnectionInfo connectInfo, String method, String sql, Executable<R> exec)
|
||||
throws SQLException {
|
||||
try {
|
||||
Span span = ContextManager.INSTANCE.createSpan("JDBC/Connection/" + method);
|
||||
Span span = ContextManager.createSpan("JDBC/Connection/" + method);
|
||||
Tags.DB_TYPE.set(span, "sql");
|
||||
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
|
||||
Tags.DB_STATEMENT.set(span, sql);
|
||||
|
|
@ -36,12 +36,12 @@ public class ConnectionTracing {
|
|||
}
|
||||
return exec.exe(realConnection, sql);
|
||||
} catch (SQLException e) {
|
||||
Span span = ContextManager.INSTANCE.activeSpan();
|
||||
Span span = ContextManager.activeSpan();
|
||||
Tags.ERROR.set(span, true);
|
||||
span.log(e);
|
||||
throw e;
|
||||
} finally {
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class PreparedStatementTracing {
|
|||
ConnectionInfo connectInfo, String method, String sql, Executable<R> exec)
|
||||
throws SQLException {
|
||||
try {
|
||||
Span span = ContextManager.INSTANCE.createSpan("JDBC/PreparedStatement/" + method);
|
||||
Span span = ContextManager.createSpan("JDBC/PreparedStatement/" + method);
|
||||
Tags.DB_TYPE.set(span, "sql");
|
||||
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
|
||||
Tags.DB_STATEMENT.set(span, sql);
|
||||
|
|
@ -35,12 +35,12 @@ public class PreparedStatementTracing {
|
|||
Tags.SPAN_LAYER.asDB(span);
|
||||
return exec.exe(realStatement, sql);
|
||||
} catch (SQLException e) {
|
||||
Span span = ContextManager.INSTANCE.activeSpan();
|
||||
Span span = ContextManager.activeSpan();
|
||||
Tags.ERROR.set(span, true);
|
||||
span.log(e);
|
||||
throw e;
|
||||
} finally {
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class StatementTracing {
|
|||
ConnectionInfo connectInfo, String method, String sql, Executable<R> exec)
|
||||
throws SQLException {
|
||||
try {
|
||||
Span span = ContextManager.INSTANCE.createSpan("JDBC/Statement/" + method);
|
||||
Span span = ContextManager.createSpan("JDBC/Statement/" + method);
|
||||
Tags.DB_TYPE.set(span, "sql");
|
||||
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
|
||||
Tags.DB_STATEMENT.set(span, sql);
|
||||
|
|
@ -35,12 +35,12 @@ public class StatementTracing {
|
|||
}
|
||||
return exec.exe(realStatement, sql);
|
||||
} catch (SQLException e) {
|
||||
Span span = ContextManager.INSTANCE.activeSpan();
|
||||
Span span = ContextManager.activeSpan();
|
||||
Tags.ERROR.set(span, true);
|
||||
span.log(e);
|
||||
throw e;
|
||||
} finally {
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.plugin.jdbc;
|
||||
|
||||
import com.a.eye.skywalking.api.boot.ServiceStarter;
|
||||
import com.a.eye.skywalking.api.context.TracerContext;
|
||||
import com.a.eye.skywalking.sniffer.mock.context.MockTracerContextListener;
|
||||
import com.a.eye.skywalking.sniffer.mock.context.SegmentAssert;
|
||||
|
|
@ -89,6 +90,7 @@ public class SWCallableStatementTest extends AbstractStatementTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
ServiceStarter.INSTANCE.boot();
|
||||
swConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306/test", new Properties(), jdbcConnection);
|
||||
multiHostConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306,127.0.0.1:3309/test", new Properties(), jdbcConnection);
|
||||
|
||||
|
|
@ -749,4 +751,4 @@ public class SWCallableStatementTest extends AbstractStatementTest {
|
|||
TracerContext.ListenerManager.remove(mockTracerContextListener);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.plugin.jdbc;
|
||||
|
||||
import com.a.eye.skywalking.api.boot.ServiceStarter;
|
||||
import com.a.eye.skywalking.api.context.TracerContext;
|
||||
import com.a.eye.skywalking.sniffer.mock.context.MockTracerContextListener;
|
||||
import com.a.eye.skywalking.sniffer.mock.context.SegmentAssert;
|
||||
|
|
@ -48,6 +49,8 @@ public class SWStatementTest extends AbstractStatementTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
|
||||
ServiceStarter.INSTANCE.boot();
|
||||
swConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306/test", new Properties(), jdbcConnection);
|
||||
multiHostConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306,127.0.0.1:3309/test", new Properties(), jdbcConnection);
|
||||
|
||||
|
|
@ -306,4 +309,4 @@ public class SWStatementTest extends AbstractStatementTest {
|
|||
public void tearDown() throws Exception {
|
||||
TracerContext.ListenerManager.remove(mockTracerContextListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.plugin.jdbc;
|
||||
|
||||
import com.a.eye.skywalking.api.boot.ServiceStarter;
|
||||
import com.a.eye.skywalking.api.context.TracerContext;
|
||||
import com.a.eye.skywalking.sniffer.mock.context.MockTracerContextListener;
|
||||
import com.a.eye.skywalking.sniffer.mock.context.SegmentAssert;
|
||||
|
|
@ -89,6 +90,8 @@ public class SwPreparedStatementTest extends AbstractStatementTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
|
||||
ServiceStarter.INSTANCE.boot();
|
||||
swConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306/test", new Properties(), jdbcConnection);
|
||||
multiHostConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306,127.0.0.1:3309/test", new Properties(), jdbcConnection);
|
||||
|
||||
|
|
@ -580,4 +583,4 @@ public class SwPreparedStatementTest extends AbstractStatementTest {
|
|||
public void tearDown() throws Exception {
|
||||
TracerContext.ListenerManager.remove(mockTracerContextListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class JedisMethodInterceptor extends NoCocurrencyAceessObject {
|
|||
this.whenEnter(context, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Span span = ContextManager.INSTANCE.createSpan("Jedis/" + interceptorContext.methodName());
|
||||
Span span = ContextManager.createSpan("Jedis/" + interceptorContext.methodName());
|
||||
Tags.COMPONENT.set(span, REDIS_COMPONENT);
|
||||
Tags.DB_TYPE.set(span, REDIS_COMPONENT);
|
||||
tagPeer(span, context);
|
||||
|
|
@ -84,7 +84,7 @@ public class JedisMethodInterceptor extends NoCocurrencyAceessObject {
|
|||
this.whenExist(context, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
|
|
@ -92,6 +92,6 @@ public class JedisMethodInterceptor extends NoCocurrencyAceessObject {
|
|||
|
||||
@Override
|
||||
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
|
||||
ContextManager.INSTANCE.activeSpan().log(t);
|
||||
ContextManager.activeSpan().log(t);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.plugin.jedis.v2;
|
||||
|
||||
import com.a.eye.skywalking.api.boot.ServiceStarter;
|
||||
import com.a.eye.skywalking.api.context.TracerContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
|
|
@ -46,6 +47,8 @@ public class JedisMethodInterceptorTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ServiceStarter.INSTANCE.boot();
|
||||
|
||||
interceptor = new JedisMethodInterceptor();
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
|
||||
|
|
@ -149,4 +152,4 @@ public class JedisMethodInterceptorTest {
|
|||
TracerContext.ListenerManager.remove(mockTracerContextListener);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class MotanConsumerInterceptor implements InstanceConstructorInterceptor,
|
|||
URL url = (URL) context.get(KEY_NAME_OF_REQUEST_URL);
|
||||
Request request = (Request) interceptorContext.allArguments()[0];
|
||||
if (url != null) {
|
||||
Span span = ContextManager.INSTANCE.createSpan(generateOperationName(url, request));
|
||||
Span span = ContextManager.createSpan(generateOperationName(url, request));
|
||||
Tags.PEER_HOST.set(span, url.getHost());
|
||||
Tags.PEER_PORT.set(span, url.getPort());
|
||||
Tags.COMPONENT.set(span, MOTAN_COMPONENT);
|
||||
|
|
@ -58,7 +58,7 @@ public class MotanConsumerInterceptor implements InstanceConstructorInterceptor,
|
|||
Tags.SPAN_LAYER.asRPCFramework(span);
|
||||
|
||||
ContextCarrier contextCarrier = new ContextCarrier();
|
||||
ContextManager.INSTANCE.inject(contextCarrier);
|
||||
ContextManager.inject(contextCarrier);
|
||||
request.setAttachment(ATTACHMENT_KEY_OF_CONTEXT_DATA, contextCarrier.serialize());
|
||||
}
|
||||
}
|
||||
|
|
@ -68,18 +68,18 @@ public class MotanConsumerInterceptor implements InstanceConstructorInterceptor,
|
|||
Object ret) {
|
||||
Response response = (Response) ret;
|
||||
if (response != null && response.getException() != null) {
|
||||
Span span = ContextManager.INSTANCE.activeSpan();
|
||||
Span span = ContextManager.activeSpan();
|
||||
Tags.ERROR.set(span, true);
|
||||
span.log(response.getException());
|
||||
}
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context,
|
||||
InstanceMethodInvokeContext interceptorContext) {
|
||||
ContextManager.INSTANCE.activeSpan().log(t);
|
||||
ContextManager.activeSpan().log(t);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,14 +37,14 @@ public class MotanProviderInterceptor implements InstanceMethodsAroundIntercepto
|
|||
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext,
|
||||
MethodInterceptResult result) {
|
||||
Request request = (Request) interceptorContext.allArguments()[0];
|
||||
Span span = ContextManager.INSTANCE.createSpan(generateViewPoint(request));
|
||||
Span span = ContextManager.createSpan(generateViewPoint(request));
|
||||
Tags.COMPONENT.set(span, MOTAN_COMPONENT);
|
||||
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_SERVER);
|
||||
Tags.SPAN_LAYER.asRPCFramework(span);
|
||||
|
||||
String serializedContextData = request.getAttachments().get(ATTACHMENT_KEY_OF_CONTEXT_DATA);
|
||||
if (!StringUtil.isEmpty(serializedContextData)) {
|
||||
ContextManager.INSTANCE.extract(new ContextCarrier().deserialize(serializedContextData));
|
||||
ContextManager.extract(new ContextCarrier().deserialize(serializedContextData));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,19 +53,19 @@ public class MotanProviderInterceptor implements InstanceMethodsAroundIntercepto
|
|||
Object ret) {
|
||||
Response response = (Response) ret;
|
||||
if (response != null && response.getException() != null) {
|
||||
Span span = ContextManager.INSTANCE.activeSpan();
|
||||
Span span = ContextManager.activeSpan();
|
||||
span.log(response.getException());
|
||||
Tags.ERROR.set(span, true);
|
||||
}
|
||||
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context,
|
||||
InstanceMethodInvokeContext interceptorContext) {
|
||||
ContextManager.INSTANCE.activeSpan().log(t);
|
||||
ContextManager.activeSpan().log(t);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.plugin.motan;
|
||||
|
||||
import com.a.eye.skywalking.api.boot.ServiceStarter;
|
||||
import com.a.eye.skywalking.api.context.TracerContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
|
|
@ -51,6 +52,8 @@ public class MotanConsumerInterceptorTest {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ServiceStarter.INSTANCE.boot();
|
||||
|
||||
contextListener = new MockTracerContextListener();
|
||||
invokeInterceptor = new MotanConsumerInterceptor();
|
||||
url = URL.valueOf("motan://127.0.0.1:34000/com.a.eye.skywalking.test.TestService");
|
||||
|
|
@ -139,4 +142,4 @@ public class MotanConsumerInterceptorTest {
|
|||
public void tearDown() {
|
||||
TracerContext.ListenerManager.remove(contextListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class TomcatInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
Object[] args = interceptorContext.allArguments();
|
||||
HttpServletRequest request = (HttpServletRequest) args[0];
|
||||
|
||||
Span span = ContextManager.INSTANCE.createSpan(request.getRequestURI());
|
||||
Span span = ContextManager.createSpan(request.getRequestURI());
|
||||
Tags.COMPONENT.set(span, TOMCAT_COMPONENT);
|
||||
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_SERVER);
|
||||
Tags.URL.set(span, request.getRequestURL().toString());
|
||||
|
|
@ -49,7 +49,7 @@ public class TomcatInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
|
||||
String tracingHeaderValue = request.getHeader(HEADER_NAME_OF_CONTEXT_DATA);
|
||||
if (!StringUtil.isEmpty(tracingHeaderValue)) {
|
||||
ContextManager.INSTANCE.extract(new ContextCarrier().deserialize(tracingHeaderValue));
|
||||
ContextManager.extract(new ContextCarrier().deserialize(tracingHeaderValue));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,21 +57,21 @@ public class TomcatInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
|
||||
HttpServletResponse response = (HttpServletResponse) interceptorContext.allArguments()[1];
|
||||
|
||||
Span span = ContextManager.INSTANCE.activeSpan();
|
||||
Span span = ContextManager.activeSpan();
|
||||
Tags.STATUS_CODE.set(span, response.getStatus());
|
||||
|
||||
if (response.getStatus() != 200) {
|
||||
Tags.ERROR.set(span, true);
|
||||
}
|
||||
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context,
|
||||
InstanceMethodInvokeContext interceptorContext) {
|
||||
Span span = ContextManager.INSTANCE.activeSpan();
|
||||
Span span = ContextManager.activeSpan();
|
||||
span.log(t);
|
||||
Tags.ERROR.set(span, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.a.eye.skywalking.plugin.tomcat78x;
|
||||
|
||||
import com.a.eye.skywalking.api.boot.ServiceStarter;
|
||||
import com.a.eye.skywalking.api.context.TracerContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
|
|
@ -48,6 +49,9 @@ public class TomcatInterceptorTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
ServiceStarter.INSTANCE.boot();
|
||||
|
||||
tomcatInterceptor = new TomcatInterceptor();
|
||||
contextListener = new MockTracerContextListener();
|
||||
|
||||
|
|
@ -139,4 +143,4 @@ public class TomcatInterceptorTest {
|
|||
TracerContext.ListenerManager.remove(new MockTracerContextListener());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import com.a.eye.skywalking.trace.tag.Tags;
|
|||
public class DubboSpanGenerator {
|
||||
public static class Client extends SpanGeneration{
|
||||
@Override protected void before() {
|
||||
Span span = ContextManager.INSTANCE.createSpan("/default_rpc/com.a.eye.skywalking.test.persistence.PersistenceService.query");
|
||||
Span span = ContextManager.createSpan("/default_rpc/com.a.eye.skywalking.test.persistence.PersistenceService.query");
|
||||
Tags.COMPONENT.set(span, "Dubbo");
|
||||
Tags.URL.set(span, "rest://192.168.1.8:20880/default_rpc/com.a.eye.skywalking.test.persistence.PersistenceService.query(String)");
|
||||
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_SERVER);
|
||||
|
|
@ -23,13 +23,13 @@ public class DubboSpanGenerator {
|
|||
}
|
||||
|
||||
@Override protected void after() {
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Server extends SpanGeneration{
|
||||
@Override protected void before() {
|
||||
Span span = ContextManager.INSTANCE.createSpan("/default_rpc/com.a.eye.skywalking.test.persistence.PersistenceService.query");
|
||||
Span span = ContextManager.createSpan("/default_rpc/com.a.eye.skywalking.test.persistence.PersistenceService.query");
|
||||
Tags.COMPONENT.set(span, "Dubbo");
|
||||
Tags.URL.set(span, "rest://192.168.1.8:20880/default_rpc/com.a.eye.skywalking.test.persistence.PersistenceService.query(String)");
|
||||
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_CLIENT);
|
||||
|
|
@ -38,7 +38,7 @@ public class DubboSpanGenerator {
|
|||
}
|
||||
|
||||
@Override protected void after() {
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import com.a.eye.skywalking.trace.tag.Tags;
|
|||
public class MySQLGenerator {
|
||||
public static class Query extends SpanGeneration {
|
||||
@Override protected void before() {
|
||||
Span span = ContextManager.INSTANCE.createSpan("mysql/jdbi/statement/executeQuery");
|
||||
Span span = ContextManager.createSpan("mysql/jdbi/statement/executeQuery");
|
||||
Tags.COMPONENT.set(span, "Mysql");
|
||||
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_CLIENT);
|
||||
Tags.PEER_HOST.set(span, "10.5.34.18");
|
||||
|
|
@ -24,7 +24,7 @@ public class MySQLGenerator {
|
|||
}
|
||||
|
||||
@Override protected void after() {
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class TomcatSpanGenerator{
|
|||
public static final ON200 INSTANCE = new ON200();
|
||||
|
||||
@Override protected void before() {
|
||||
Span webSpan = ContextManager.INSTANCE.createSpan("/web/serviceA");
|
||||
Span webSpan = ContextManager.createSpan("/web/serviceA");
|
||||
Tags.COMPONENT.set(webSpan, "Tomcat");
|
||||
Tags.URL.set(webSpan, "http://10.21.9.35/web/serviceA");
|
||||
Tags.SPAN_KIND.set(webSpan, Tags.SPAN_KIND_SERVER);
|
||||
|
|
@ -24,9 +24,9 @@ public class TomcatSpanGenerator{
|
|||
}
|
||||
|
||||
@Override protected void after() {
|
||||
Span webSpan = ContextManager.INSTANCE.activeSpan();
|
||||
Span webSpan = ContextManager.activeSpan();
|
||||
Tags.STATUS_CODE.set(webSpan, 200);
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ public class TomcatSpanGenerator{
|
|||
public static final ON404 INSTANCE = new ON404();
|
||||
|
||||
@Override protected void before() {
|
||||
Span webSpan = ContextManager.INSTANCE.createSpan("/web/service/unknown");
|
||||
Span webSpan = ContextManager.createSpan("/web/service/unknown");
|
||||
Tags.COMPONENT.set(webSpan, "Tomcat");
|
||||
Tags.URL.set(webSpan, "http://10.21.9.35/web/unknown");
|
||||
Tags.SPAN_KIND.set(webSpan, Tags.SPAN_KIND_SERVER);
|
||||
|
|
@ -44,17 +44,17 @@ public class TomcatSpanGenerator{
|
|||
}
|
||||
|
||||
@Override protected void after() {
|
||||
Span webSpan = ContextManager.INSTANCE.activeSpan();
|
||||
Span webSpan = ContextManager.activeSpan();
|
||||
Tags.STATUS_CODE.set(webSpan, 404);
|
||||
Tags.ERROR.set(webSpan,true);
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
}
|
||||
public static class ON500 extends SpanGeneration{
|
||||
public static final ON500 INSTANCE = new ON500();
|
||||
|
||||
@Override protected void before() {
|
||||
Span webSpan = ContextManager.INSTANCE.createSpan("/web/error/service");
|
||||
Span webSpan = ContextManager.createSpan("/web/error/service");
|
||||
Tags.COMPONENT.set(webSpan, "Tomcat");
|
||||
Tags.URL.set(webSpan, "http://10.21.9.35/web/error/service");
|
||||
Tags.SPAN_KIND.set(webSpan, Tags.SPAN_KIND_SERVER);
|
||||
|
|
@ -64,11 +64,11 @@ public class TomcatSpanGenerator{
|
|||
}
|
||||
|
||||
@Override protected void after() {
|
||||
Span webSpan = ContextManager.INSTANCE.activeSpan();
|
||||
Span webSpan = ContextManager.activeSpan();
|
||||
Tags.STATUS_CODE.set(webSpan, 500);
|
||||
Tags.ERROR.set(webSpan,true);
|
||||
webSpan.log(new NumberFormatException("Can't convert 'abc' to int."));
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,23 @@
|
|||
package com.a.eye.skywalking.sniffer.mock;
|
||||
|
||||
import com.a.eye.skywalking.api.boot.ServiceStarter;
|
||||
import com.a.eye.skywalking.sniffer.mock.context.MockTracerContextListener;
|
||||
import com.a.eye.skywalking.sniffer.mock.context.SegmentAssert;
|
||||
import com.a.eye.skywalking.sniffer.mock.trace.TraceSegmentBuilderFactory;
|
||||
import com.a.eye.skywalking.trace.TraceSegment;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/21.
|
||||
*/
|
||||
public class MockTracerContextListenerTestCase {
|
||||
@BeforeClass
|
||||
public static void setup(){
|
||||
ServiceStarter.INSTANCE.boot();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterFinished(){
|
||||
MockTracerContextListener listener = new MockTracerContextListener();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class PrintTraceIdInterceptor implements InstanceMethodsAroundInterceptor
|
|||
*/
|
||||
@Override
|
||||
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
|
||||
return "TID:" + ContextManager.INSTANCE.getTraceSegmentId();
|
||||
return "TID:" + ContextManager.getTraceSegmentId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class PrintTraceIdInterceptor implements StaticMethodsAroundInterceptor {
|
|||
*/
|
||||
@Override
|
||||
public void beforeMethod(StaticMethodInvokeContext interceptorContext, MethodInterceptResult result) {
|
||||
((StringBuilder) interceptorContext.allArguments()[0]).append("TID:" + ContextManager.INSTANCE.getTraceSegmentId());
|
||||
((StringBuilder) interceptorContext.allArguments()[0]).append("TID:" + ContextManager.getTraceSegmentId());
|
||||
|
||||
//make sure origin method do not invoke.
|
||||
result.defineReturnValue(null);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class PrintTraceIdInterceptor implements InstanceMethodsAroundInterceptor
|
|||
*/
|
||||
@Override
|
||||
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
|
||||
return "TID:" + ContextManager.INSTANCE.getTraceSegmentId();
|
||||
return "TID:" + ContextManager.getTraceSegmentId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-toolkit-opentracing</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ public class SpanFinishInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
Object[] allArguments = interceptorContext.allArguments();
|
||||
|
||||
if(allArguments.length == 1) {
|
||||
ContextManager.INSTANCE.stopSpan(((Long)allArguments[0]));
|
||||
ContextManager.stopSpan(((Long)allArguments[0]));
|
||||
}else{
|
||||
ContextManager.INSTANCE.stopSpan();
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class SpanNewInstanceInterceptor implements InstanceConstructorIntercepto
|
|||
String operationName = ((String)allArguments[0]);
|
||||
long startTime = ((Long)allArguments[1]);
|
||||
Map<String, String> tags = ((Map<String, String>)allArguments[2]);
|
||||
Span span = ContextManager.INSTANCE.createSpan(operationName, startTime);
|
||||
Span span = ContextManager.createSpan(operationName, startTime);
|
||||
|
||||
for (Map.Entry<String, String> entry : tags.entrySet()) {
|
||||
span.setTag(entry.getKey(), entry.getValue());
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class SpanSetOperationNameInterceptor implements InstanceMethodsAroundInt
|
|||
@Override
|
||||
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
|
||||
String operationName = (String)interceptorContext.allArguments()[0];
|
||||
ContextManager.INSTANCE.activeSpan().setOperationName(operationName);
|
||||
ContextManager.activeSpan().setOperationName(operationName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ public class SpanSetTagInterceptor implements InstanceMethodsAroundInterceptor {
|
|||
String key = (String)interceptorContext.allArguments()[0];
|
||||
Object value = interceptorContext.allArguments()[1];
|
||||
if (value instanceof String)
|
||||
ContextManager.INSTANCE.activeSpan().setTag(key, (String)value);
|
||||
ContextManager.activeSpan().setTag(key, (String)value);
|
||||
else if (value instanceof Boolean)
|
||||
ContextManager.INSTANCE.activeSpan().setTag(key, (Boolean)value);
|
||||
ContextManager.activeSpan().setTag(key, (Boolean)value);
|
||||
else if (value instanceof Number)
|
||||
ContextManager.INSTANCE.activeSpan().setTag(key, (Number)value);
|
||||
ContextManager.activeSpan().setTag(key, (Number)value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class TracerExtractCrossProcessByteBufferContextInterceptor implements In
|
|||
ContextCarrier carrier = new ContextCarrier();
|
||||
carrier.deserialize(contextDataStr);
|
||||
|
||||
ContextManager.INSTANCE.extract(carrier);
|
||||
ContextManager.extract(carrier);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class TracerExtractCrossProcessTextMapContextInterceptor implements Insta
|
|||
ContextCarrier carrier = new ContextCarrier();
|
||||
carrier.deserialize(entry.getValue());
|
||||
|
||||
ContextManager.INSTANCE.extract(carrier);
|
||||
ContextManager.extract(carrier);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class TracerFormatCrossProcessContextInterceptor implements InstanceMetho
|
|||
@Override
|
||||
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
|
||||
ContextCarrier carrier = new ContextCarrier();
|
||||
ContextManager.INSTANCE.inject(carrier);
|
||||
ContextManager.inject(carrier);
|
||||
return carrier.serialize();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package com.a.eye.skywalking.toolkit.activation.trace;
|
|||
|
||||
import com.a.eye.skywalking.api.context.ContextCarrier;
|
||||
import com.a.eye.skywalking.api.context.ContextManager;
|
||||
import com.a.eye.skywalking.api.logging.ILog;
|
||||
import com.a.eye.skywalking.api.logging.LogManager;
|
||||
import com.a.eye.skywalking.logging.ILog;
|
||||
import com.a.eye.skywalking.logging.LogManager;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInvokeContext;
|
||||
import com.a.eye.skywalking.api.plugin.interceptor.enhance.StaticMethodInvokeContext;
|
||||
|
|
@ -25,7 +25,7 @@ public class TraceContextInterceptor implements StaticMethodsAroundInterceptor {
|
|||
@Override
|
||||
public Object afterMethod(StaticMethodInvokeContext interceptorContext, Object ret) {
|
||||
ContextCarrier carrier = new ContextCarrier();
|
||||
ContextManager.INSTANCE.inject(carrier);
|
||||
ContextManager.inject(carrier);
|
||||
return carrier.getTraceSegmentId();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue