From 738d156495c223563ca1e4f49822ddf072a11077 Mon Sep 17 00:00:00 2001 From: wusheng Date: Mon, 13 Mar 2017 15:57:51 +0800 Subject: [PATCH] Recover logging-api/logging-log4j2 modules. Adjust codes for new modules. --- skywalking-collector/pom.xml | 33 +------- .../skywalking-collector-cluster/pom.xml | 13 +--- .../collector/actor/AbstractMember.java | 7 +- .../collector/actor/AbstractWorker.java | 7 +- .../actor/AbstractWorkerProvider.java | 7 +- .../skywalking/collector/actor/WorkerRef.java | 6 +- .../collector/actor/WorkersCreator.java | 6 +- .../cluster/ClusterConfigInitializer.java | 7 +- .../collector/cluster/WorkersListener.java | 6 +- .../skywalking-collector-worker/pom.xml | 12 ++- .../worker/CollectorBootStartUp.java | 4 + .../collector/worker/JsonSerializer.java | 5 -- skywalking-commons/pom.xml | 2 + .../skywalking-logging-api/pom.xml | 15 ++++ .../com/a/eye/skywalking}/logging/ILog.java | 2 +- .../a/eye/skywalking}/logging/LogManager.java | 2 +- .../eye/skywalking}/logging/LogResolver.java | 2 +- .../a/eye/skywalking}/logging/NoopLogger.java | 2 +- .../skywalking}/logging/LogManagerTest.java | 18 +---- .../skywalking}/logging/NoopLoggerTest.java | 5 +- .../skywalking-logging-log4j2/pom.xml | 31 ++++++++ .../logging/log4j2/Log4j2Logger.java | 76 +++++++++++++++++++ .../logging/log4j2/Log4j2Resolver.java | 17 +++++ .../dependency-reduced-pom.xml | 44 ++++++++++- skywalking-sniffer/skywalking-agent/pom.xml | 39 +++++++++- .../eye/skywalking/agent/SkyWalkingAgent.java | 7 +- skywalking-sniffer/skywalking-api/pom.xml | 20 +++-- .../eye/skywalking/api/boot/BootService.java | 12 +++ .../skywalking/api/boot/ServiceStarter.java | 41 ++++++++++ .../api/boot/StatusBootService.java | 32 ++++++++ .../api/conf/SnifferConfigInitializer.java | 4 +- .../api/context/ContextManager.java | 48 ++++++------ .../api/logging/EasyLogResolver.java | 3 + .../skywalking/api/logging/EasyLogger.java | 1 + .../AbstractClassEnhancePluginDefine.java | 4 +- .../api/plugin/PluginBootstrap.java | 5 +- .../api/plugin/PluginResourcesResolver.java | 4 +- .../api/plugin/TracingBootstrap.java | 4 +- .../enhance/ClassConstructorInterceptor.java | 4 +- .../enhance/ClassEnhancePluginDefine.java | 4 +- .../ClassInstanceMethodsInterceptor.java | 4 +- .../ClassStaticMethodsInterceptor.java | 4 +- .../DefaultClassConstructorInterceptor.java | 5 +- .../loader/InterceptorInstanceLoader.java | 5 +- .../api/queue/TraceSegmentProcessQueue.java | 36 ++++----- .../com.a.eye.skywalking.api.boot.BootService | 2 + .../api/context/ContextManagerTestCase.java | 6 +- .../plugin/dubbo/DubboInterceptor.java | 10 +-- .../plugin/dubbo/DubboInterceptorTest.java | 5 +- .../httpClient-4.x-plugin/pom.xml | 2 +- .../v4/HttpClientExecuteInterceptor.java | 14 ++-- .../v4/HttpClientExecuteInterceptorTest.java | 5 +- .../plugin/jdbc/CallableStatementTracing.java | 6 +- .../plugin/jdbc/ConnectionTracing.java | 6 +- .../plugin/jdbc/PreparedStatementTracing.java | 6 +- .../plugin/jdbc/StatementTracing.java | 6 +- .../plugin/jdbc/SWCallableStatementTest.java | 4 +- .../plugin/jdbc/SWStatementTest.java | 5 +- .../plugin/jdbc/SwPreparedStatementTest.java | 5 +- .../jedis/v2/JedisMethodInterceptor.java | 6 +- .../jedis/v2/JedisMethodInterceptorTest.java | 5 +- .../motan/MotanConsumerInterceptor.java | 10 +-- .../motan/MotanProviderInterceptor.java | 10 +-- .../motan/MotanConsumerInterceptorTest.java | 5 +- .../plugin/tomcat78x/TomcatInterceptor.java | 10 +-- .../tomcat78x/TomcatInterceptorTest.java | 6 +- .../builders/span/DubboSpanGenerator.java | 8 +- .../trace/builders/span/MySQLGenerator.java | 4 +- .../builders/span/TomcatSpanGenerator.java | 18 ++--- .../MockTracerContextListenerTestCase.java | 7 ++ .../log4j/v1/x/PrintTraceIdInterceptor.java | 2 +- .../log4j/v2/x/PrintTraceIdInterceptor.java | 2 +- .../logback/v1/x/PrintTraceIdInterceptor.java | 2 +- .../pom.xml | 1 + .../interceptor/SpanFinishInterceptor.java | 4 +- .../SpanNewInstanceInterceptor.java | 2 +- .../SpanSetOperationNameInterceptor.java | 2 +- .../interceptor/SpanSetTagInterceptor.java | 6 +- ...ssProcessByteBufferContextInterceptor.java | 2 +- ...CrossProcessTextMapContextInterceptor.java | 2 +- ...rFormatCrossProcessContextInterceptor.java | 2 +- .../trace/TraceContextInterceptor.java | 6 +- 82 files changed, 563 insertions(+), 256 deletions(-) create mode 100644 skywalking-commons/skywalking-logging-api/pom.xml rename {skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api => skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking}/logging/ILog.java (94%) rename {skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api => skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking}/logging/LogManager.java (96%) rename {skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api => skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking}/logging/LogResolver.java (88%) rename {skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api => skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking}/logging/NoopLogger.java (96%) rename {skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api => skywalking-commons/skywalking-logging-api/src/test/java/com/a/eye/skywalking}/logging/LogManagerTest.java (77%) rename {skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api => skywalking-commons/skywalking-logging-api/src/test/java/com/a/eye/skywalking}/logging/NoopLoggerTest.java (87%) create mode 100644 skywalking-commons/skywalking-logging-log4j2/pom.xml create mode 100644 skywalking-commons/skywalking-logging-log4j2/src/main/java/com/a/eye/skywalking/logging/log4j2/Log4j2Logger.java create mode 100644 skywalking-commons/skywalking-logging-log4j2/src/main/java/com/a/eye/skywalking/logging/log4j2/Log4j2Resolver.java create mode 100644 skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/BootService.java create mode 100644 skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/ServiceStarter.java create mode 100644 skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/StatusBootService.java create mode 100644 skywalking-sniffer/skywalking-api/src/main/resources/META-INF/services/com.a.eye.skywalking.api.boot.BootService diff --git a/skywalking-collector/pom.xml b/skywalking-collector/pom.xml index 720bcff1e..9cb030442 100644 --- a/skywalking-collector/pom.xml +++ b/skywalking-collector/pom.xml @@ -24,36 +24,6 @@ akka-cluster_2.11 ${akka.version} - - com.typesafe.akka - akka-cluster-metrics_2.11 - ${akka.version} - - - com.typesafe.akka - akka-cluster-tools_2.11 - ${akka.version} - - - com.typesafe.akka - akka-persistence_2.11 - ${akka.version} - - - org.iq80.leveldb - leveldb - 0.9 - - - org.apache.logging.log4j - log4j-core - 2.8 - - - org.apache.logging.log4j - log4j-api - 2.8 - com.typesafe.akka akka-testkit_2.11 @@ -62,9 +32,8 @@ com.a.eye - skywalking-sniffer-mock + skywalking-logging-api ${project.version} - test diff --git a/skywalking-collector/skywalking-collector-cluster/pom.xml b/skywalking-collector/skywalking-collector-cluster/pom.xml index 0f40be50a..86c2681eb 100644 --- a/skywalking-collector/skywalking-collector-cluster/pom.xml +++ b/skywalking-collector/skywalking-collector-cluster/pom.xml @@ -17,19 +17,14 @@ - javax.inject - javax.inject - 1 + com.a.eye + skywalking-util + ${project.version} com.lmax disruptor 3.3.6 - - com.a.eye - skywalking-api - ${project.version} - - \ No newline at end of file + diff --git a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractMember.java b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractMember.java index 6f7c72a6d..81188e0c9 100644 --- a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractMember.java +++ b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractMember.java @@ -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 { - private Logger logger = LogManager.getFormatterLogger(AbstractMember.class); + private ILog logger = LogManager.getLogger(AbstractMember.class); private ActorRef actorRef; diff --git a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractWorker.java b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractWorker.java index 758ae2ff8..8216a51f2 100644 --- a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractWorker.java +++ b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractWorker.java @@ -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()); diff --git a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractWorkerProvider.java b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractWorkerProvider.java index e4bd13727..f5f829da4 100644 --- a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractWorkerProvider.java +++ b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractWorkerProvider.java @@ -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 AbstractWorkerProvider should be implemented by any class whose @@ -28,8 +28,7 @@ import org.apache.logging.log4j.Logger; *

*/ public abstract class AbstractWorkerProvider { - - private Logger logger = LogManager.getFormatterLogger(AbstractWorkerProvider.class); + private ILog logger = LogManager.getLogger(AbstractWorkerProvider.class); public abstract Class workerClass(); diff --git a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/WorkerRef.java b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/WorkerRef.java index 64a8a939b..92637fe8d 100644 --- a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/WorkerRef.java +++ b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/WorkerRef.java @@ -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; diff --git a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/WorkersCreator.java b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/WorkersCreator.java index c4b88371c..550956f8c 100644 --- a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/WorkersCreator.java +++ b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/WorkersCreator.java @@ -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. diff --git a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/cluster/ClusterConfigInitializer.java b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/cluster/ClusterConfigInitializer.java index e37feafa9..f16ad7d86 100644 --- a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/cluster/ClusterConfigInitializer.java +++ b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/cluster/ClusterConfigInitializer.java @@ -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"; diff --git a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/cluster/WorkersListener.java b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/cluster/WorkersListener.java index 86491cf15..244c57645 100644 --- a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/cluster/WorkersListener.java +++ b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/cluster/WorkersListener.java @@ -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; /** * WorkersListener 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"; diff --git a/skywalking-collector/skywalking-collector-worker/pom.xml b/skywalking-collector/skywalking-collector-worker/pom.xml index 15ff30c96..58087d109 100644 --- a/skywalking-collector/skywalking-collector-worker/pom.xml +++ b/skywalking-collector/skywalking-collector-worker/pom.xml @@ -18,6 +18,16 @@ skywalking-collector-cluster ${project.version} + + com.a.eye + skywalking-trace + ${project.version} + + + com.a.eye + skywalking-logging-log4j2 + ${project.version} + com.google.code.gson gson @@ -35,4 +45,4 @@ test - \ No newline at end of file + diff --git a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/CollectorBootStartUp.java b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/CollectorBootStartUp.java index ceab05e73..a60907557 100644 --- a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/CollectorBootStartUp.java +++ b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/CollectorBootStartUp.java @@ -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). diff --git a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/JsonSerializer.java b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/JsonSerializer.java index 985003fce..bade0def9 100644 --- a/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/JsonSerializer.java +++ b/skywalking-collector/skywalking-collector-worker/src/main/java/com/a/eye/skywalking/collector/worker/JsonSerializer.java @@ -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); } diff --git a/skywalking-commons/pom.xml b/skywalking-commons/pom.xml index 6a5ef732e..dd721fcf4 100644 --- a/skywalking-commons/pom.xml +++ b/skywalking-commons/pom.xml @@ -13,6 +13,8 @@ skywalking-trace skywalking-util + skywalking-logging-api + skywalking-logging-log4j2 skywalking-commons diff --git a/skywalking-commons/skywalking-logging-api/pom.xml b/skywalking-commons/skywalking-logging-api/pom.xml new file mode 100644 index 000000000..df272ae6b --- /dev/null +++ b/skywalking-commons/skywalking-logging-api/pom.xml @@ -0,0 +1,15 @@ + + + + skywalking-commons + com.a.eye + 3.0-2017 + + 4.0.0 + + skywalking-logging-api + + + diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/ILog.java b/skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/ILog.java similarity index 94% rename from skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/ILog.java rename to skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/ILog.java index a7de245d5..9cb718d2e 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/ILog.java +++ b/skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/ILog.java @@ -1,4 +1,4 @@ -package com.a.eye.skywalking.api.logging; +package com.a.eye.skywalking.logging; /** * The Log interface. diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/LogManager.java b/skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/LogManager.java similarity index 96% rename from skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/LogManager.java rename to skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/LogManager.java index e290ac040..f9e69b756 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/LogManager.java +++ b/skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/LogManager.java @@ -1,4 +1,4 @@ -package com.a.eye.skywalking.api.logging; +package com.a.eye.skywalking.logging; /** * LogManager is the {@link LogResolver} implementation manager. diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/LogResolver.java b/skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/LogResolver.java similarity index 88% rename from skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/LogResolver.java rename to skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/LogResolver.java index 3c751c6ef..c465afb35 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/LogResolver.java +++ b/skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/LogResolver.java @@ -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. diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/NoopLogger.java b/skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/NoopLogger.java similarity index 96% rename from skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/NoopLogger.java rename to skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/NoopLogger.java index be261815e..30b48a752 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/NoopLogger.java +++ b/skywalking-commons/skywalking-logging-api/src/main/java/com/a/eye/skywalking/logging/NoopLogger.java @@ -1,4 +1,4 @@ -package com.a.eye.skywalking.api.logging; +package com.a.eye.skywalking.logging; /** diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/logging/LogManagerTest.java b/skywalking-commons/skywalking-logging-api/src/test/java/com/a/eye/skywalking/logging/LogManagerTest.java similarity index 77% rename from skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/logging/LogManagerTest.java rename to skywalking-commons/skywalking-logging-api/src/test/java/com/a/eye/skywalking/logging/LogManagerTest.java index 7a44a3215..f3ae1f708 100644 --- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/logging/LogManagerTest.java +++ b/skywalking-commons/skywalking-logging-api/src/test/java/com/a/eye/skywalking/logging/LogManagerTest.java @@ -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 { } } -} +} diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/logging/NoopLoggerTest.java b/skywalking-commons/skywalking-logging-api/src/test/java/com/a/eye/skywalking/logging/NoopLoggerTest.java similarity index 87% rename from skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/logging/NoopLoggerTest.java rename to skywalking-commons/skywalking-logging-api/src/test/java/com/a/eye/skywalking/logging/NoopLoggerTest.java index 7aafebb55..3b4fa1bb6 100644 --- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/logging/NoopLoggerTest.java +++ b/skywalking-commons/skywalking-logging-api/src/test/java/com/a/eye/skywalking/logging/NoopLoggerTest.java @@ -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. diff --git a/skywalking-commons/skywalking-logging-log4j2/pom.xml b/skywalking-commons/skywalking-logging-log4j2/pom.xml new file mode 100644 index 000000000..5fbe227ba --- /dev/null +++ b/skywalking-commons/skywalking-logging-log4j2/pom.xml @@ -0,0 +1,31 @@ + + + + skywalking-commons + com.a.eye + 3.0-2017 + + 4.0.0 + + skywalking-logging-log4j2 + + + + com.a.eye + skywalking-logging-api + ${project.version} + + + org.apache.logging.log4j + log4j-core + 2.8 + + + org.apache.logging.log4j + log4j-api + 2.8 + + + diff --git a/skywalking-commons/skywalking-logging-log4j2/src/main/java/com/a/eye/skywalking/logging/log4j2/Log4j2Logger.java b/skywalking-commons/skywalking-logging-log4j2/src/main/java/com/a/eye/skywalking/logging/log4j2/Log4j2Logger.java new file mode 100644 index 000000000..ea6d4a65c --- /dev/null +++ b/skywalking-commons/skywalking-logging-log4j2/src/main/java/com/a/eye/skywalking/logging/log4j2/Log4j2Logger.java @@ -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); + } +} diff --git a/skywalking-commons/skywalking-logging-log4j2/src/main/java/com/a/eye/skywalking/logging/log4j2/Log4j2Resolver.java b/skywalking-commons/skywalking-logging-log4j2/src/main/java/com/a/eye/skywalking/logging/log4j2/Log4j2Resolver.java new file mode 100644 index 000000000..47008ccdc --- /dev/null +++ b/skywalking-commons/skywalking-logging-log4j2/src/main/java/com/a/eye/skywalking/logging/log4j2/Log4j2Resolver.java @@ -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 LogResolver is an implementation of {@link LogResolver}, + * + * + * @author wusheng + */ +public class Log4j2Resolver implements LogResolver { + @Override + public ILog getLogger(Class clazz) { + return new Log4j2Logger(clazz); + } +} diff --git a/skywalking-sniffer/skywalking-agent/dependency-reduced-pom.xml b/skywalking-sniffer/skywalking-agent/dependency-reduced-pom.xml index 2f7d3c750..47d71df53 100644 --- a/skywalking-sniffer/skywalking-agent/dependency-reduced-pom.xml +++ b/skywalking-sniffer/skywalking-agent/dependency-reduced-pom.xml @@ -45,6 +45,30 @@ ${shade.com.lmax.disruptor.source} ${shade.com.lmax.disruptor.target} + + ${shade.akka.source} + ${shade.akka.target} + + + ${shade.com.google.source} + ${shade.com.google.target} + + + ${shade.all.org.source} + ${shade.all.org.target} + + + ${shade.scala.source} + ${shade.scala.target} + + + ${shade.io.aeron.source} + ${shade.io.aeron.target} + + + ${shade.com.typesafe.source} + ${shade.com.typesafe.target} + @@ -112,13 +136,25 @@ - ${shade.package}.${shade.net.bytebuddy.source} - com.a.eye.skywalking.api.dependencies - UTF-8 - com.lmax.disruptor + ${shade.package}.${shade.com.typesafe.source} ${shade.package}.${shade.com.lmax.disruptor.source} net.bytebuddy + ${shade.package}.${shade.akka.source} + ${shade.package}.${shade.io.aeron.source} + ${shade.package}.${shade.all.org.source} + UTF-8 + scala + ${shade.package}.${shade.net.bytebuddy.source} + com.a.eye.skywalking.dependencies + com.google + ${shade.package}.${shade.scala.source} + com.typesafe + com.lmax.disruptor + akka com.a.eye.skywalking.agent.SkyWalkingAgent + io.aeron + org + ${shade.package}.${shade.com.google.source} diff --git a/skywalking-sniffer/skywalking-agent/pom.xml b/skywalking-sniffer/skywalking-agent/pom.xml index 513a9b4e2..69a6b93c8 100644 --- a/skywalking-sniffer/skywalking-agent/pom.xml +++ b/skywalking-sniffer/skywalking-agent/pom.xml @@ -16,13 +16,24 @@ UTF-8 - com.a.eye.skywalking.api.dependencies + com.a.eye.skywalking.dependencies com.a.eye.skywalking.agent.SkyWalkingAgent net.bytebuddy ${shade.package}.${shade.net.bytebuddy.source} - com.lmax.disruptor ${shade.package}.${shade.com.lmax.disruptor.source} + akka + ${shade.package}.${shade.akka.source} + scala + ${shade.package}.${shade.scala.source} + org + ${shade.package}.${shade.all.org.source} + com.google + ${shade.package}.${shade.com.google.source} + io.aeron + ${shade.package}.${shade.io.aeron.source} + com.typesafe + ${shade.package}.${shade.com.typesafe.source} @@ -127,6 +138,30 @@ ${shade.com.lmax.disruptor.source} ${shade.com.lmax.disruptor.target} + + ${shade.akka.source} + ${shade.akka.target} + + + ${shade.com.google.source} + ${shade.com.google.target} + + + ${shade.all.org.source} + ${shade.all.org.target} + + + ${shade.scala.source} + ${shade.scala.target} + + + ${shade.io.aeron.source} + ${shade.io.aeron.target} + + + ${shade.com.typesafe.source} + ${shade.com.typesafe.target} + diff --git a/skywalking-sniffer/skywalking-agent/src/main/java/com/a/eye/skywalking/agent/SkyWalkingAgent.java b/skywalking-sniffer/skywalking-agent/src/main/java/com/a/eye/skywalking/agent/SkyWalkingAgent.java index 173ca6d4c..8e9cdeca7 100644 --- a/skywalking-sniffer/skywalking-agent/src/main/java/com/a/eye/skywalking/agent/SkyWalkingAgent.java +++ b/skywalking-sniffer/skywalking-agent/src/main/java/com/a/eye/skywalking/agent/SkyWalkingAgent.java @@ -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()); diff --git a/skywalking-sniffer/skywalking-api/pom.xml b/skywalking-sniffer/skywalking-api/pom.xml index 943a1f8a5..9b94ddb5c 100644 --- a/skywalking-sniffer/skywalking-api/pom.xml +++ b/skywalking-sniffer/skywalking-api/pom.xml @@ -20,16 +20,26 @@ - - net.bytebuddy - byte-buddy - 1.5.7 - com.a.eye skywalking-trace ${project.version} + + com.a.eye + skywalking-logging-api + ${project.version} + + + com.a.eye + skywalking-collector-cluster + ${project.version} + + + net.bytebuddy + byte-buddy + 1.5.7 + com.lmax disruptor diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/BootService.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/BootService.java new file mode 100644 index 000000000..3bf4bf6ec --- /dev/null +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/BootService.java @@ -0,0 +1,12 @@ +package com.a.eye.skywalking.api.boot; + +/** + * The BootService is an interface to all services, which need to boot when plugin mechanism begins to + * work. + * {@link #bootUp()} will be called when BootService start up. + * + * @author wusheng + */ +public interface BootService { + void bootUp(); +} diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/ServiceStarter.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/ServiceStarter.java new file mode 100644 index 000000000..97a7d9bb1 --- /dev/null +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/ServiceStarter.java @@ -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 ServiceStarter 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 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 load() { + return ServiceLoader.load(BootService.class); + } +} diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/StatusBootService.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/StatusBootService.java new file mode 100644 index 000000000..39ee43b18 --- /dev/null +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/StatusBootService.java @@ -0,0 +1,32 @@ +package com.a.eye.skywalking.api.boot; + +/** + * The StatusBootService is an abstract implementations of {@link BootService}, + * it extends {@link BootService}'s ability like this: + * + * If an implementation extends StatusBootService, 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(); +} diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/conf/SnifferConfigInitializer.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/conf/SnifferConfigInitializer.java index dd37d05a6..40e3a4648 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/conf/SnifferConfigInitializer.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/conf/SnifferConfigInitializer.java @@ -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; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextManager.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextManager.java index 415fd9c23..0b0a4a7e2 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextManager.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextManager.java @@ -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 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(); + } } diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/EasyLogResolver.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/EasyLogResolver.java index 31f33e38d..268d83474 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/EasyLogResolver.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/EasyLogResolver.java @@ -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. */ diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/EasyLogger.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/EasyLogger.java index ac8ee73b8..200c255e3 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/EasyLogger.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/logging/EasyLogger.java @@ -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; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/AbstractClassEnhancePluginDefine.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/AbstractClassEnhancePluginDefine.java index dda08f385..0430c4af3 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/AbstractClassEnhancePluginDefine.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/AbstractClassEnhancePluginDefine.java @@ -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; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/PluginBootstrap.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/PluginBootstrap.java index 67ed10029..5926c77cb 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/PluginBootstrap.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/PluginBootstrap.java @@ -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; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/PluginResourcesResolver.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/PluginResourcesResolver.java index d5e871436..a59269cad 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/PluginResourcesResolver.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/PluginResourcesResolver.java @@ -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; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/TracingBootstrap.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/TracingBootstrap.java index d886ec395..5a2e960c5 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/TracingBootstrap.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/TracingBootstrap.java @@ -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; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassConstructorInterceptor.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassConstructorInterceptor.java index c5dd3e8ec..4093ed1d7 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassConstructorInterceptor.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassConstructorInterceptor.java @@ -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; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassEnhancePluginDefine.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassEnhancePluginDefine.java index 79336c34f..8c9ccc336 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassEnhancePluginDefine.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassEnhancePluginDefine.java @@ -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; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassInstanceMethodsInterceptor.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassInstanceMethodsInterceptor.java index e0e17414c..5a2a23903 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassInstanceMethodsInterceptor.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassInstanceMethodsInterceptor.java @@ -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.*; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassStaticMethodsInterceptor.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassStaticMethodsInterceptor.java index 0c2d01f17..863f6d5db 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassStaticMethodsInterceptor.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/ClassStaticMethodsInterceptor.java @@ -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; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/DefaultClassConstructorInterceptor.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/DefaultClassConstructorInterceptor.java index 9f240a98f..4155e8a03 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/DefaultClassConstructorInterceptor.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/enhance/DefaultClassConstructorInterceptor.java @@ -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; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/loader/InterceptorInstanceLoader.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/loader/InterceptorInstanceLoader.java index 9cfc7d050..78addb934 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/loader/InterceptorInstanceLoader.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/plugin/interceptor/loader/InterceptorInstanceLoader.java @@ -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; diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/queue/TraceSegmentProcessQueue.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/queue/TraceSegmentProcessQueue.java index 5da3cc5ec..f8eff6e6f 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/queue/TraceSegmentProcessQueue.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/queue/TraceSegmentProcessQueue.java @@ -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 disruptor; + private RingBuffer 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 disruptor; - RingBuffer 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(); - } } diff --git a/skywalking-sniffer/skywalking-api/src/main/resources/META-INF/services/com.a.eye.skywalking.api.boot.BootService b/skywalking-sniffer/skywalking-api/src/main/resources/META-INF/services/com.a.eye.skywalking.api.boot.BootService new file mode 100644 index 000000000..a305b07a5 --- /dev/null +++ b/skywalking-sniffer/skywalking-api/src/main/resources/META-INF/services/com.a.eye.skywalking.api.boot.BootService @@ -0,0 +1,2 @@ +com.a.eye.skywalking.api.queue.TraceSegmentProcessQueue +com.a.eye.skywalking.api.context.ContextManager diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/ContextManagerTestCase.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/ContextManagerTestCase.java index 017d70cac..f0b092a0b 100644 --- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/ContextManagerTestCase.java +++ b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/ContextManagerTestCase.java @@ -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]; diff --git a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptor.java index 1ce09301f..6c8e1570d 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/main/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptor.java @@ -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); } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptorTest.java b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptorTest.java index f0714dfc0..65afb04f3 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptorTest.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/dubbo-plugin/src/test/java/com/a/eye/skywalking/plugin/dubbo/DubboInterceptorTest.java @@ -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); } -} \ No newline at end of file +} diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/pom.xml b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/pom.xml index 9ffbd6fec..4d13cff6b 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/pom.xml +++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/pom.xml @@ -23,7 +23,7 @@ com.a.eye skywalking-api - 3.0-2017 + ${project.version} diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java index e2bf4650e..7030ddc6c 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java @@ -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); } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/test/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/test/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java index d8c7f3faa..7a0c26f89 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/test/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/test/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java @@ -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); } -} \ No newline at end of file +} diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/CallableStatementTracing.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/CallableStatementTracing.java index a0633b121..1c1463577 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/CallableStatementTracing.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/CallableStatementTracing.java @@ -22,7 +22,7 @@ public class CallableStatementTracing { ConnectionInfo connectInfo, String method, String sql, Executable 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(); } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/ConnectionTracing.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/ConnectionTracing.java index 62fb7f9c1..6bfb1706a 100755 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/ConnectionTracing.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/ConnectionTracing.java @@ -22,7 +22,7 @@ public class ConnectionTracing { ConnectionInfo connectInfo, String method, String sql, Executable 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(); } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/PreparedStatementTracing.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/PreparedStatementTracing.java index 8823721be..09ca3c5e3 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/PreparedStatementTracing.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/PreparedStatementTracing.java @@ -21,7 +21,7 @@ public class PreparedStatementTracing { ConnectionInfo connectInfo, String method, String sql, Executable 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(); } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/StatementTracing.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/StatementTracing.java index 364422340..8d4776521 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/StatementTracing.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/main/java/com/a/eye/skywalking/plugin/jdbc/StatementTracing.java @@ -21,7 +21,7 @@ public class StatementTracing { ConnectionInfo connectInfo, String method, String sql, Executable 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(); } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SWCallableStatementTest.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SWCallableStatementTest.java index 1861eceba..f3fefe2c3 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SWCallableStatementTest.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SWCallableStatementTest.java @@ -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); } -} \ No newline at end of file +} diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SWStatementTest.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SWStatementTest.java index fe8738c9e..15e3376c3 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SWStatementTest.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SWStatementTest.java @@ -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); } -} \ No newline at end of file +} diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SwPreparedStatementTest.java b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SwPreparedStatementTest.java index f2c6822bb..d370891a5 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SwPreparedStatementTest.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jdbc-plugin/src/test/java/com/a/eye/skywalking/plugin/jdbc/SwPreparedStatementTest.java @@ -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); } -} \ No newline at end of file +} diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisMethodInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisMethodInterceptor.java index b7d795433..01b9655c7 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisMethodInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/main/java/com/a/eye/skywalking/plugin/jedis/v2/JedisMethodInterceptor.java @@ -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); } } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/test/java/com/a/eye/skywalking/plugin/jedis/v2/JedisMethodInterceptorTest.java b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/test/java/com/a/eye/skywalking/plugin/jedis/v2/JedisMethodInterceptorTest.java index 650d3191e..f447bd39f 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/test/java/com/a/eye/skywalking/plugin/jedis/v2/JedisMethodInterceptorTest.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/jedis-2.x-plugin/src/test/java/com/a/eye/skywalking/plugin/jedis/v2/JedisMethodInterceptorTest.java @@ -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); } -} \ No newline at end of file +} diff --git a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanConsumerInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanConsumerInterceptor.java index bbddc5899..28f9bf128 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanConsumerInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanConsumerInterceptor.java @@ -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); } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanProviderInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanProviderInterceptor.java index 51d4a94e2..20d9611a5 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanProviderInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/main/java/com/a/eye/skywalking/plugin/motan/MotanProviderInterceptor.java @@ -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); } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/test/java/com/a/eye/skywalking/plugin/motan/MotanConsumerInterceptorTest.java b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/test/java/com/a/eye/skywalking/plugin/motan/MotanConsumerInterceptorTest.java index 199c79678..fe25327c8 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/test/java/com/a/eye/skywalking/plugin/motan/MotanConsumerInterceptorTest.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/motan-plugin/src/test/java/com/a/eye/skywalking/plugin/motan/MotanConsumerInterceptorTest.java @@ -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); } -} \ No newline at end of file +} diff --git a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatInterceptor.java b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatInterceptor.java index 07f518113..0c3475b88 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatInterceptor.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatInterceptor.java @@ -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); } diff --git a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatInterceptorTest.java b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatInterceptorTest.java index 61f8501d8..47c19cc13 100644 --- a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatInterceptorTest.java +++ b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/com/a/eye/skywalking/plugin/tomcat78x/TomcatInterceptorTest.java @@ -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()); } -} \ No newline at end of file +} diff --git a/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/DubboSpanGenerator.java b/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/DubboSpanGenerator.java index fdba25e7a..d9c709a2b 100644 --- a/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/DubboSpanGenerator.java +++ b/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/DubboSpanGenerator.java @@ -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(); } } } diff --git a/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/MySQLGenerator.java b/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/MySQLGenerator.java index 78097f919..e08324c28 100644 --- a/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/MySQLGenerator.java +++ b/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/MySQLGenerator.java @@ -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(); } } } diff --git a/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/TomcatSpanGenerator.java b/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/TomcatSpanGenerator.java index 5a37ba71f..1db497352 100644 --- a/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/TomcatSpanGenerator.java +++ b/skywalking-sniffer/skywalking-sniffer-mock/src/main/java/com/a/eye/skywalking/sniffer/mock/trace/builders/span/TomcatSpanGenerator.java @@ -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(); } } } diff --git a/skywalking-sniffer/skywalking-sniffer-mock/src/test/java/com/a/eye/skywalking/sniffer/mock/MockTracerContextListenerTestCase.java b/skywalking-sniffer/skywalking-sniffer-mock/src/test/java/com/a/eye/skywalking/sniffer/mock/MockTracerContextListenerTestCase.java index 83f1d34b4..abf074a3d 100644 --- a/skywalking-sniffer/skywalking-sniffer-mock/src/test/java/com/a/eye/skywalking/sniffer/mock/MockTracerContextListenerTestCase.java +++ b/skywalking-sniffer/skywalking-sniffer-mock/src/test/java/com/a/eye/skywalking/sniffer/mock/MockTracerContextListenerTestCase.java @@ -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(); diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/PrintTraceIdInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/PrintTraceIdInterceptor.java index 83a46851c..917a57e77 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/PrintTraceIdInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/PrintTraceIdInterceptor.java @@ -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 diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/PrintTraceIdInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/PrintTraceIdInterceptor.java index fa848a18c..3ced73776 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/PrintTraceIdInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/PrintTraceIdInterceptor.java @@ -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); diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/PrintTraceIdInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/PrintTraceIdInterceptor.java index f1d4c52c6..afa630192 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/PrintTraceIdInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/PrintTraceIdInterceptor.java @@ -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 diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/pom.xml b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/pom.xml index 6b26be230..d159c4e6b 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/pom.xml +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/pom.xml @@ -21,6 +21,7 @@ com.a.eye skywalking-toolkit-opentracing ${project.version} + provided diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanFinishInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanFinishInterceptor.java index e008ffcf7..d3a74ec60 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanFinishInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanFinishInterceptor.java @@ -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; diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanNewInstanceInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanNewInstanceInterceptor.java index 73967ca7a..c1099782b 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanNewInstanceInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanNewInstanceInterceptor.java @@ -19,7 +19,7 @@ public class SpanNewInstanceInterceptor implements InstanceConstructorIntercepto String operationName = ((String)allArguments[0]); long startTime = ((Long)allArguments[1]); Map tags = ((Map)allArguments[2]); - Span span = ContextManager.INSTANCE.createSpan(operationName, startTime); + Span span = ContextManager.createSpan(operationName, startTime); for (Map.Entry entry : tags.entrySet()) { span.setTag(entry.getKey(), entry.getValue()); diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetOperationNameInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetOperationNameInterceptor.java index 7f46ac393..f324ddfd3 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetOperationNameInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetOperationNameInterceptor.java @@ -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 diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java index 35d5ae3ec..028ea37c6 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java @@ -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 diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessByteBufferContextInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessByteBufferContextInterceptor.java index f8c978c38..9c5c2b181 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessByteBufferContextInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessByteBufferContextInterceptor.java @@ -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; } diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessTextMapContextInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessTextMapContextInterceptor.java index 5541a219f..9e4223930 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessTextMapContextInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessTextMapContextInterceptor.java @@ -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; diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerFormatCrossProcessContextInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerFormatCrossProcessContextInterceptor.java index ed87a94d0..9152e6e2c 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerFormatCrossProcessContextInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerFormatCrossProcessContextInterceptor.java @@ -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(); } diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextInterceptor.java index d7f8a57c6..f3715e652 100644 --- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextInterceptor.java +++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextInterceptor.java @@ -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(); }