修复部分问题

This commit is contained in:
ascrutae 2016-12-06 14:30:19 +08:00
parent 27a2d53a8b
commit 7aefb8f8a6
2 changed files with 6 additions and 6 deletions

View File

@ -77,12 +77,12 @@ public class Span {
this.parentLevel = "";
}
public Span(TraceId traceId, String parentLevel, int levelId, String applicationCode, String username) {
public Span(TraceId traceId, String parentLevel, int levelId, String applicationCode, String username, String viewPointId) {
this.traceId = traceId;
this.parentLevel = parentLevel;
this.levelId = levelId;
this.applicationId = applicationId;
this.userId = userId;
this.applicationCode = applicationCode;
this.username = username;
this.viewPointId = viewPointId;
this.routeKey = RoutingKeyGenerator.generate(viewPointId);
}

View File

@ -29,7 +29,7 @@ public final class ContextGenerator {
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.USER_ID, id.getViewPoint());
Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USERNAME, id.getViewPoint());
} else {
spanData = getSpanFromThreadLocal(id);
}
@ -45,14 +45,14 @@ public final class ContextGenerator {
int routeKey;
if (parentSpan == null) {
// 不存在新创建一个Context
span = new Span(TraceIdGenerator.generate(), Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USER_ID);
span = new Span(TraceIdGenerator.generate(), Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USERNAME);
routeKey = RoutingKeyGenerator.generate(id.getViewPoint());
} else {
// 根据ParentContextData的TraceId和RPCID
// LevelId是由SpanNode类的nextSubSpanLevelId字段进行初始化的.
// 所以在这里不需要初始化
span = new Span(parentSpan.getTraceId(), Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USER_ID);
span = new Span(parentSpan.getTraceId(), Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USERNAME);
if (!StringUtil.isEmpty(parentSpan.getParentLevel())) {
span.setParentLevel(parentSpan.getParentLevel() + "." + parentSpan.getLevelId());
} else {