1. 修复对ContextData对象序列化时没有对ParentLevelId进行判空处理,导致序号不一致问题
This commit is contained in:
parent
0103a3dd37
commit
485870e141
|
|
@ -23,11 +23,11 @@ public class ContextData {
|
|||
public ContextData(String contextDataStr) {
|
||||
// 反序列化参数
|
||||
String[] value = contextDataStr.split("-");
|
||||
if(value == null || value.length != 4){
|
||||
throw new IllegalArgumentException("illegal context data.");
|
||||
if (value == null || value.length != 4) {
|
||||
throw new IllegalArgumentException("illegal context data.");
|
||||
}
|
||||
this.traceId = value[0];
|
||||
this.parentLevel = value[1];
|
||||
this.parentLevel = value[1].trim();
|
||||
this.levelId = Integer.valueOf(value[2]);
|
||||
this.spanType = value[3];
|
||||
|
||||
|
|
@ -51,6 +51,18 @@ public class ContextData {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return traceId + "-" + parentLevel + "-" + levelId + "-" + spanType;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(traceId);
|
||||
stringBuilder.append("-");
|
||||
if (parentLevel != null && parentLevel.length() > 0) {
|
||||
stringBuilder.append(" ");
|
||||
} else {
|
||||
stringBuilder.append(parentLevel);
|
||||
}
|
||||
stringBuilder.append("-");
|
||||
stringBuilder.append(levelId);
|
||||
stringBuilder.append("-");
|
||||
stringBuilder.append(spanType);
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue