修复部分问题
This commit is contained in:
parent
3be4fb38e0
commit
469ce5ea90
|
|
@ -29,27 +29,32 @@
|
|||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-jedis-2.x-plugin</artifactId>
|
||||
<version>2.0-2016</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-jdbc-plugin</artifactId>
|
||||
<version>2.0-2016</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-httpClient-4.x-plugin</artifactId>
|
||||
<version>2.0-2016</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>skywalking-dubbo-plugin</artifactId>
|
||||
<version>2.0-2016</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>tomcat-7.x-8.x-plugin</artifactId>
|
||||
<version>2.0-2016</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.a.eye</groupId>
|
||||
<artifactId>motan-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
* 当前调用链的上级描述<br/>
|
||||
* 如当前序号为:0.1.0时,parentLevel=0.1
|
||||
*/
|
||||
protected String parentLevel;
|
||||
protected String parentLevel;
|
||||
/**
|
||||
* 当前调用链的本机描述<br/>
|
||||
* 如当前序号为:0.1.0时,levelId=0
|
||||
|
|
@ -42,7 +45,7 @@ public class Span {
|
|||
* 1:异常<br/>
|
||||
* 异常判断原则:代码产生exception,并且此exception不在忽略列表中
|
||||
*/
|
||||
protected byte statusCode = 0;
|
||||
protected byte statusCode = 0;
|
||||
/**
|
||||
* 节点调用的错误堆栈<br/>
|
||||
* 堆栈以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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1
|
||||
|
|
@ -1 +0,0 @@
|
|||
JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1
|
||||
|
|
@ -1 +0,0 @@
|
|||
JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1
|
||||
|
|
@ -1 +0,0 @@
|
|||
JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1
|
||||
|
|
@ -1 +0,0 @@
|
|||
JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1JappR1
|
||||
Loading…
Reference in New Issue