diff --git a/skywalking-sniffer/skywalking-agent/pom.xml b/skywalking-sniffer/skywalking-agent/pom.xml index 611871c3c..666c2beb0 100644 --- a/skywalking-sniffer/skywalking-agent/pom.xml +++ b/skywalking-sniffer/skywalking-agent/pom.xml @@ -29,27 +29,32 @@ com.a.eye skywalking-jedis-2.x-plugin - 2.0-2016 + ${project.version} com.a.eye skywalking-jdbc-plugin - 2.0-2016 + ${project.version} com.a.eye skywalking-httpClient-4.x-plugin - 2.0-2016 + ${project.version} com.a.eye skywalking-dubbo-plugin - 2.0-2016 + ${project.version} com.a.eye tomcat-7.x-8.x-plugin - 2.0-2016 + ${project.version} + + + com.a.eye + motan-plugin + ${project.version} diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/model/ContextData.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/model/ContextData.java index 03fd4e3ec..6ef512a3e 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/model/ContextData.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/model/ContextData.java @@ -10,13 +10,13 @@ public class ContextData { private TraceId traceId; private String parentLevel; private int levelId; - private long routeKey; + private int routeKey; ContextData() { } - public ContextData(TraceId traceId, String parentLevelId, long routeKey) { + public ContextData(TraceId traceId, String parentLevelId, int routeKey) { this.traceId = traceId; this.parentLevel = parentLevelId; this.routeKey = routeKey; @@ -53,7 +53,7 @@ public class ContextData { this.traceId = traceIdBuilder.build(); this.parentLevel = value[1].trim(); this.levelId = Integer.valueOf(value[2]); - this.routeKey = Long.parseLong(value[3]); + this.routeKey = Integer.parseInt(value[3]); } public TraceId getTraceId() { @@ -68,6 +68,10 @@ public class ContextData { return levelId; } + public int getRouteKey(){ + return this.routeKey; + } + @Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/model/Span.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/model/Span.java index 9f0db257f..4cc9971e1 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/model/Span.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/model/Span.java @@ -1,10 +1,13 @@ package com.a.eye.skywalking.model; +import com.a.eye.skywalking.conf.Config; import com.a.eye.skywalking.network.grpc.AckSpan; import com.a.eye.skywalking.network.grpc.RequestSpan; import com.a.eye.skywalking.network.grpc.TraceId; import com.a.eye.skywalking.util.RoutingKeyGenerator; +import com.a.eye.skywalking.util.StringUtil; +import com.a.eye.skywalking.util.TraceIdGenerator; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -24,7 +27,7 @@ public class Span { * 当前调用链的上级描述
* 如当前序号为:0.1.0时,parentLevel=0.1 */ - protected String parentLevel; + protected String parentLevel; /** * 当前调用链的本机描述
* 如当前序号为:0.1.0时,levelId=0 @@ -42,7 +45,7 @@ public class Span { * 1:异常
* 异常判断原则:代码产生exception,并且此exception不在忽略列表中 */ - protected byte statusCode = 0; + protected byte statusCode = 0; /** * 节点调用的错误堆栈
* 堆栈以JAVA的exception为主要判断依据 @@ -68,23 +71,28 @@ public class Span { */ private String username; private String viewPointId; - private int routeKey; + private int routeKey; - public Span(TraceId traceId, String applicationCode, String username) { - this.traceId = traceId; - this.applicationCode = applicationCode; - this.username = username; - this.parentLevel = ""; + public Span(String operationName) { + this(TraceIdGenerator.generate(), "", 0, operationName, RoutingKeyGenerator.generate(operationName)); } - public Span(TraceId traceId, String parentLevel, int levelId, String applicationCode, String username, String viewPointId) { + public Span(Span parentSpan, String operationName) { + this(parentSpan.traceId, parentSpan.generateParentLevelId(), 0, operationName,parentSpan.getRouteKey()); + } + + public Span(ContextData contextData, String operationName) { + this(contextData.getTraceId(), contextData.getParentLevel(), contextData.getLevelId(), operationName, contextData.getRouteKey()); + } + + private Span(TraceId traceId, String parentLevel, int levelId, String operationName, int routeKey) { this.traceId = traceId; this.parentLevel = parentLevel; this.levelId = levelId; - this.applicationCode = applicationCode; - this.username = username; - this.viewPointId = viewPointId; - this.routeKey = RoutingKeyGenerator.generate(viewPointId); + this.applicationCode = Config.SkyWalking.APPLICATION_CODE; + this.username = Config.SkyWalking.USERNAME; + this.routeKey = routeKey; + this.viewPointId = operationName; } public TraceId getTraceId() { @@ -205,7 +213,7 @@ public class Span { return builder; } - public AckSpan.Builder buildAckSpan(AckSpan.Builder builder){ + public AckSpan.Builder buildAckSpan(AckSpan.Builder builder) { builder.setTraceId(this.traceId).setParentLevel(this.parentLevel).setLevelId(this.levelId) .setCost(System.currentTimeMillis() - this.startDate).setStatusCode(this.statusCode) .setExceptionStack(this.exceptionStack).setUsername(this.username).setApplicationCode(this.applicationCode) @@ -220,4 +228,12 @@ public class Span { public int getRouteKey() { return routeKey; } + + private String generateParentLevelId() { + if (!StringUtil.isEmpty(this.getParentLevel())) { + return this.getParentLevel() + "." + this.getLevelId(); + } else { + return String.valueOf(this.getLevelId()); + } + } } diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/util/ContextGenerator.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/util/ContextGenerator.java index bad6e9c80..6b43f5ee6 100644 --- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/util/ContextGenerator.java +++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/util/ContextGenerator.java @@ -1,6 +1,5 @@ package com.a.eye.skywalking.util; -import com.a.eye.skywalking.conf.Config; import com.a.eye.skywalking.context.CurrentThreadSpanStack; import com.a.eye.skywalking.model.ContextData; import com.a.eye.skywalking.model.Identification; @@ -28,8 +27,7 @@ public final class ContextGenerator { public static Span generateSpanFromContextData(ContextData context, Identification id) { Span spanData = CurrentThreadSpanStack.peek(); if (context != null && context.getTraceId() != null && spanData == null) { - spanData = new Span(context.getTraceId(), context.getParentLevel(), context.getLevelId(), - Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USERNAME, id.getViewPoint()); + spanData = new Span(context, id.getViewPoint()); } else { spanData = getSpanFromThreadLocal(id); } @@ -42,28 +40,17 @@ public final class ContextGenerator { // 1.获取Context,从ThreadLocal栈中获取中 final Span parentSpan = CurrentThreadSpanStack.peek(); // 2 校验Context,Context是否存在 - int routeKey; if (parentSpan == null) { // 不存在,新创建一个Context - span = new Span(TraceIdGenerator.generate(), Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USERNAME); - routeKey = RoutingKeyGenerator.generate(id.getViewPoint()); + span = new Span(id.getViewPoint()); } else { - // 根据ParentContextData的TraceId和RPCID // LevelId是由SpanNode类的nextSubSpanLevelId字段进行初始化的. // 所以在这里不需要初始化 - span = new Span(parentSpan.getTraceId(), Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USERNAME); - if (!StringUtil.isEmpty(parentSpan.getParentLevel())) { - span.setParentLevel(parentSpan.getParentLevel() + "." + parentSpan.getLevelId()); - } else { - span.setParentLevel(String.valueOf(parentSpan.getLevelId())); - } - routeKey = parentSpan.getRouteKey(); + span = new Span(parentSpan, id.getViewPoint()); } span.setStartDate(System.currentTimeMillis()); - span.setViewPointId(id.getViewPoint()); - span.setRouteKey(routeKey); return span; } diff --git a/skywalking-storage-center/data/file/2016_12_05_14_26_19_094_1000 b/skywalking-storage-center/data/file/2016_12_05_14_26_19_094_1000 deleted file mode 100644 index 89cb71e14..000000000 --- a/skywalking-storage-center/data/file/2016_12_05_14_26_19_094_1000 +++ /dev/null @@ -1 +0,0 @@ -JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1 \ No newline at end of file diff --git a/skywalking-storage-center/data/file/2016_12_05_14_28_56_230_1000 b/skywalking-storage-center/data/file/2016_12_05_14_28_56_230_1000 deleted file mode 100644 index 89cb71e14..000000000 --- a/skywalking-storage-center/data/file/2016_12_05_14_28_56_230_1000 +++ /dev/null @@ -1 +0,0 @@ -JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1 \ No newline at end of file diff --git a/skywalking-storage-center/data/file/2016_12_05_19_19_19_996_1000 b/skywalking-storage-center/data/file/2016_12_05_19_19_19_996_1000 deleted file mode 100644 index 89cb71e14..000000000 --- a/skywalking-storage-center/data/file/2016_12_05_19_19_19_996_1000 +++ /dev/null @@ -1 +0,0 @@ -JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1 \ No newline at end of file diff --git a/skywalking-storage-center/data/file/2016_12_06_16_24_50_333_1000 b/skywalking-storage-center/data/file/2016_12_06_16_24_50_333_1000 deleted file mode 100644 index 89cb71e14..000000000 --- a/skywalking-storage-center/data/file/2016_12_06_16_24_50_333_1000 +++ /dev/null @@ -1 +0,0 @@ -JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1 \ No newline at end of file diff --git a/skywalking-storage-center/data/file/2016_12_06_16_55_18_667_1000 b/skywalking-storage-center/data/file/2016_12_06_16_55_18_667_1000 deleted file mode 100644 index 89cb71e14..000000000 --- a/skywalking-storage-center/data/file/2016_12_06_16_55_18_667_1000 +++ /dev/null @@ -1 +0,0 @@ -JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1 \ No newline at end of file