提交 942899b4 编写于 作者: A ascrutae

修复部分问题

上级 528226ef
......@@ -53,6 +53,7 @@
</dependency>
</dependencies>
<build>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......
......@@ -6,7 +6,5 @@ public class Constants {
*/
public static int SDK_VERSION = 202016;
public static final String HEALTH_DATA_SPILT_PATTERN = "^~";
public static final String DATA_SPILT = "#&";
public static final String CONTEXT_DATA_SEGMENT_SPILT_CHAR = "#&";
}
......@@ -4,6 +4,8 @@ package com.a.eye.skywalking.model;
import com.a.eye.skywalking.api.Tracing;
import com.a.eye.skywalking.network.grpc.TraceId;
import static com.a.eye.skywalking.conf.Constants.CONTEXT_DATA_SEGMENT_SPILT_CHAR;
public class ContextData {
private TraceId traceId;
private String parentLevel;
......@@ -29,12 +31,12 @@ public class ContextData {
public ContextData(String contextDataStr) {
// 反序列化参数
String[] value = contextDataStr.split("-");
String[] value = contextDataStr.split(CONTEXT_DATA_SEGMENT_SPILT_CHAR);
if (value == null || value.length != 4) {
throw new IllegalArgumentException("illegal context");
}
String traceIdStr = value[0];
String[] traceIdSegments = traceIdStr.split(",");
String[] traceIdSegments = traceIdStr.split("\\.");
if(traceIdSegments == null || traceIdSegments.length != 6){
throw new IllegalArgumentException("illegal traceid in context");
}
......@@ -71,15 +73,15 @@ public class ContextData {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(Tracing.formatTraceId(traceId));
stringBuilder.append("-");
stringBuilder.append(CONTEXT_DATA_SEGMENT_SPILT_CHAR);
if (parentLevel == null || parentLevel.length() == 0) {
stringBuilder.append(" ");
} else {
stringBuilder.append(parentLevel);
}
stringBuilder.append("-");
stringBuilder.append(CONTEXT_DATA_SEGMENT_SPILT_CHAR);
stringBuilder.append(levelId);
stringBuilder.append("-");
stringBuilder.append(CONTEXT_DATA_SEGMENT_SPILT_CHAR);
stringBuilder.append(routeKey);
return stringBuilder.toString();
}
......
......@@ -4,6 +4,7 @@ package com.a.eye.skywalking.model;
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 java.io.ByteArrayOutputStream;
import java.io.IOException;
......@@ -76,12 +77,14 @@ public class Span {
this.parentLevel = "";
}
public Span(TraceId traceId, String parentLevel, int levelId, String applicationId, String userId) {
public Span(TraceId traceId, String parentLevel, int levelId, String applicationId, String userId, String viewPointId) {
this.traceId = traceId;
this.parentLevel = parentLevel;
this.levelId = levelId;
this.applicationId = applicationId;
this.userId = userId;
this.viewPointId = viewPointId;
this.routeKey = RoutingKeyGenerator.generate(viewPointId);
}
public TraceId getTraceId() {
......
......@@ -28,7 +28,8 @@ 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.USER_ID);
spanData = new Span(context.getTraceId(), context.getParentLevel(), context.getLevelId(),
Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USER_ID, id.getViewPoint());
} else {
spanData = getSpanFromThreadLocal(id);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册