完成所有插件测试
This commit is contained in:
parent
76bae4c9e7
commit
f4efee4ea5
|
|
@ -27,7 +27,14 @@ public class RPCClientInvokeMonitor extends BaseInvokeMonitor {
|
|||
//设置SpanType的类型
|
||||
spanData.setSpanType(SpanType.RPC_CLIENT);
|
||||
|
||||
ContextBuffer.save(new RequestSpan(spanData));
|
||||
RequestSpan requestSpan = RequestSpan.RequestSpanBuilder.newBuilder(spanData)
|
||||
.viewPoint(id.getViewPoint())
|
||||
.spanTypeDesc(id.getSpanTypeDesc())
|
||||
.bussinessKey(id.getBusinessKey())
|
||||
.callType(id.getCallType())
|
||||
.parameters(id.getParameters()).build();
|
||||
|
||||
ContextBuffer.save(requestSpan);
|
||||
CurrentThreadSpanStack.push(spanData);
|
||||
|
||||
return new ContextData(spanData.getTraceId(), generateSubParentLevelId(spanData));
|
||||
|
|
|
|||
|
|
@ -16,15 +16,18 @@ import static com.ai.cloud.skywalking.conf.Config.Logging.LOG_FILE_PATH;
|
|||
|
||||
public class SyncFileWriter implements IFileWriter {
|
||||
|
||||
private static SyncFileWriter writer;
|
||||
private FileOutputStream os;
|
||||
private int bufferSize;
|
||||
private static SyncFileWriter writer;
|
||||
private FileOutputStream os;
|
||||
private int bufferSize;
|
||||
private static final Object lock = new Object();
|
||||
|
||||
private SyncFileWriter() {
|
||||
try {
|
||||
os = new FileOutputStream(new File(LOG_FILE_PATH,
|
||||
LOG_FILE_NAME), true);
|
||||
File logFilePath = new File(LOG_FILE_PATH);
|
||||
if (!logFilePath.exists()) {
|
||||
logFilePath.mkdirs();
|
||||
}
|
||||
os = new FileOutputStream(new File(LOG_FILE_PATH, LOG_FILE_NAME), true);
|
||||
bufferSize = Long.valueOf(new File(LOG_FILE_PATH, LOG_FILE_NAME).length()).intValue();
|
||||
} catch (IOException e) {
|
||||
writeErrorLog(e);
|
||||
|
|
@ -73,15 +76,12 @@ public class SyncFileWriter implements IFileWriter {
|
|||
}
|
||||
|
||||
private void revertInputStream() throws FileNotFoundException {
|
||||
os = new FileOutputStream(new File(Config.Logging.LOG_FILE_PATH,
|
||||
Config.Logging.LOG_FILE_NAME), true);
|
||||
os = new FileOutputStream(new File(Config.Logging.LOG_FILE_PATH, Config.Logging.LOG_FILE_NAME), true);
|
||||
}
|
||||
|
||||
private void renameLogFile() {
|
||||
new File(Config.Logging.LOG_FILE_PATH, Config.Logging.LOG_FILE_NAME)
|
||||
.renameTo(new File(Config.Logging.LOG_FILE_PATH,
|
||||
Config.Logging.LOG_FILE_NAME +
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
|
||||
.renameTo(new File(Config.Logging.LOG_FILE_PATH, Config.Logging.LOG_FILE_NAME + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
|
||||
}
|
||||
|
||||
private void closeInputStream() throws IOException {
|
||||
|
|
|
|||
|
|
@ -26,13 +26,12 @@ public class ContextData {
|
|||
public ContextData(String contextDataStr) {
|
||||
// 反序列化参数
|
||||
String[] value = contextDataStr.split("-");
|
||||
if (value == null || value.length != 4) {
|
||||
if (value == null || value.length != 3) {
|
||||
throw new IllegalArgumentException("illegal context data.");
|
||||
}
|
||||
this.traceId = value[0];
|
||||
this.parentLevel = value[1].trim();
|
||||
this.levelId = Integer.valueOf(value[2]);
|
||||
|
||||
}
|
||||
|
||||
public String getTraceId() {
|
||||
|
|
|
|||
|
|
@ -3,22 +3,27 @@ package com.ai.cloud.skywalking.model;
|
|||
import com.ai.cloud.skywalking.api.IBuriedPointType;
|
||||
import com.ai.cloud.skywalking.protocol.util.StringUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Identification {
|
||||
private String viewPoint;
|
||||
private String businessKey;
|
||||
private String spanTypeDesc;
|
||||
private String callType;
|
||||
private String viewPoint;
|
||||
private Map<String, String> parameters;
|
||||
private String businessKey;
|
||||
private String spanTypeDesc;
|
||||
private String callType;
|
||||
|
||||
public Identification() {
|
||||
//Non
|
||||
parameters = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
public String getViewPoint() {
|
||||
return viewPoint;
|
||||
}
|
||||
|
||||
public String getBusinessKey() {
|
||||
return businessKey;
|
||||
public Map<String, String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public String getSpanTypeDesc() {
|
||||
|
|
@ -29,6 +34,11 @@ public class Identification {
|
|||
return callType;
|
||||
}
|
||||
|
||||
public String getBusinessKey() {
|
||||
return businessKey;
|
||||
}
|
||||
|
||||
|
||||
public static IdentificationBuilder newBuilder() {
|
||||
return new IdentificationBuilder();
|
||||
}
|
||||
|
|
@ -49,6 +59,11 @@ public class Identification {
|
|||
return this;
|
||||
}
|
||||
|
||||
public IdentificationBuilder appendParameter(String key, String value) {
|
||||
sendData.parameters.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IdentificationBuilder businessKey(String businessKey) {
|
||||
sendData.businessKey = businessKey;
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -1,69 +1,59 @@
|
|||
package com.ai.cloud.skywalking.plugin.interceptor.enhance;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.ai.cloud.skywalking.logging.LogManager;
|
||||
import com.ai.cloud.skywalking.logging.Logger;
|
||||
import net.bytebuddy.implementation.bind.annotation.AllArguments;
|
||||
import net.bytebuddy.implementation.bind.annotation.Origin;
|
||||
import net.bytebuddy.implementation.bind.annotation.RuntimeType;
|
||||
import net.bytebuddy.implementation.bind.annotation.SuperCall;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* 类静态方法拦截、控制器
|
||||
*
|
||||
* @author wusheng
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class ClassStaticMethodsInterceptor {
|
||||
private static Logger logger = LogManager
|
||||
.getLogger(ClassStaticMethodsInterceptor.class);
|
||||
private static Logger logger = LogManager.getLogger(ClassStaticMethodsInterceptor.class);
|
||||
|
||||
private StaticMethodsAroundInterceptor interceptor;
|
||||
private StaticMethodsAroundInterceptor interceptor;
|
||||
|
||||
public ClassStaticMethodsInterceptor(
|
||||
StaticMethodsAroundInterceptor interceptor) {
|
||||
this.interceptor = interceptor;
|
||||
}
|
||||
public ClassStaticMethodsInterceptor(StaticMethodsAroundInterceptor interceptor) {
|
||||
this.interceptor = interceptor;
|
||||
}
|
||||
|
||||
@RuntimeType
|
||||
public Object intercept(@Origin Class<?> clazz,
|
||||
@AllArguments Object[] allArguments, @Origin Method method,
|
||||
@SuperCall Callable<?> zuper) throws Exception {
|
||||
MethodInvokeContext interceptorContext = new MethodInvokeContext(
|
||||
method.getName(), allArguments);
|
||||
MethodInterceptResult result = new MethodInterceptResult();
|
||||
try {
|
||||
interceptor.beforeMethod(interceptorContext, result);
|
||||
} catch (Throwable t) {
|
||||
logger.error("class[{}] before static method[{}] intercept failue:{}",
|
||||
clazz, method.getName(), t.getMessage(), t);
|
||||
}
|
||||
if(!result.isContinue()){
|
||||
return result._ret();
|
||||
}
|
||||
|
||||
Object ret = null;
|
||||
try {
|
||||
ret = zuper.call();
|
||||
} catch (Throwable t) {
|
||||
try {
|
||||
interceptor.handleMethodException(t, interceptorContext, ret);
|
||||
} catch (Throwable t2) {
|
||||
logger.error("class[{}] handle static method[{}] exception failue:{}",
|
||||
clazz, method.getName(), t2.getMessage(), t2);
|
||||
}
|
||||
throw t;
|
||||
} finally {
|
||||
try {
|
||||
ret = interceptor.afterMethod(interceptorContext, ret);
|
||||
} catch (Throwable t) {
|
||||
logger.error("class[{}] after static method[{}] intercept failue:{}",
|
||||
clazz, method.getName(), t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@RuntimeType
|
||||
public Object intercept(@Origin Class<?> clazz, @AllArguments Object[] allArguments, @Origin Method method, @SuperCall Callable<?> zuper) throws Exception {
|
||||
MethodInvokeContext interceptorContext = new MethodInvokeContext(method.getName(), allArguments);
|
||||
MethodInterceptResult result = new MethodInterceptResult();
|
||||
try {
|
||||
interceptor.beforeMethod(interceptorContext, result);
|
||||
} catch (Throwable t) {
|
||||
logger.error("class[{}] before static method[{}] intercept failue:{}", new Object[] {clazz, method.getName(), t.getMessage()}, t);
|
||||
}
|
||||
if (!result.isContinue()) {
|
||||
return result._ret();
|
||||
}
|
||||
|
||||
Object ret = null;
|
||||
try {
|
||||
ret = zuper.call();
|
||||
} catch (Throwable t) {
|
||||
try {
|
||||
interceptor.handleMethodException(t, interceptorContext, ret);
|
||||
} catch (Throwable t2) {
|
||||
logger.error("class[{}] handle static method[{}] exception failue:{}", new Object[] {clazz, method.getName(), t2.getMessage()}, t2);
|
||||
}
|
||||
throw t;
|
||||
} finally {
|
||||
try {
|
||||
ret = interceptor.afterMethod(interceptorContext, ret);
|
||||
} catch (Throwable t) {
|
||||
logger.error("class[{}] after static method[{}] intercept failue:{}", new Object[] {clazz, method.getName(), t.getMessage()}, t);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ai.cloud.skywalking.protocol.util;
|
||||
|
||||
import com.ai.cloud.skywalking.conf.Config;
|
||||
import com.ai.cloud.skywalking.context.CurrentThreadSpanStack;
|
||||
import com.ai.cloud.skywalking.model.ContextData;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
|
|
@ -16,6 +17,7 @@ public final class ContextGenerator {
|
|||
public static Span generateSpanFromThreadLocal(Identification id) {
|
||||
Span spanData = getSpanFromThreadLocal();
|
||||
spanData.setStartDate(System.currentTimeMillis());
|
||||
spanData.appendParameters(id.getParameters());
|
||||
return spanData;
|
||||
}
|
||||
|
||||
|
|
@ -31,10 +33,10 @@ public final class ContextGenerator {
|
|||
// 校验传入的参数是否为空,如果为空,则新创建一个
|
||||
if (context == null || StringUtil.isEmpty(context.getTraceId())) {
|
||||
// 不存在,新创建一个Context
|
||||
spanData = new Span(TraceIdGenerator.generate());
|
||||
spanData = new Span(TraceIdGenerator.generate(), Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USER_ID);
|
||||
} else {
|
||||
// 如果不为空,则将当前的Context存放到上下文
|
||||
spanData = new Span(context.getTraceId(), context.getParentLevel(), context.getLevelId());
|
||||
spanData = new Span(context.getTraceId(), context.getParentLevel(), context.getLevelId(), Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USER_ID);
|
||||
}
|
||||
|
||||
spanData.setStartDate(System.currentTimeMillis());
|
||||
|
|
@ -49,13 +51,13 @@ public final class ContextGenerator {
|
|||
// 2 校验Context,Context是否存在
|
||||
if (parentSpan == null) {
|
||||
// 不存在,新创建一个Context
|
||||
span = new Span(TraceIdGenerator.generate());
|
||||
span = new Span(TraceIdGenerator.generate(), Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USER_ID);
|
||||
} else {
|
||||
|
||||
// 根据ParentContextData的TraceId和RPCID
|
||||
// LevelId是由SpanNode类的nextSubSpanLevelId字段进行初始化的.
|
||||
// 所以在这里不需要初始化
|
||||
span = new Span(parentSpan.getTraceId());
|
||||
span = new Span(parentSpan.getTraceId(), Config.SkyWalking.APPLICATION_CODE, Config.SkyWalking.USER_ID);
|
||||
|
||||
// check parent span is RPC span
|
||||
// if true, current span is invalidate and current span also belong to RPC span
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ package test.ai.cloud.assertspandata;
|
|||
|
||||
import com.ai.cloud.skywalking.buffer.ContextBuffer;
|
||||
import com.ai.cloud.skywalking.conf.Config;
|
||||
import com.ai.skywalking.testframework.api.TraceTreeAssert;
|
||||
|
||||
import com.ai.cloud.skywalking.protocol.RequestSpan;
|
||||
import com.ai.cloud.skywalking.protocol.Span;
|
||||
import com.ai.skywalking.testframework.api.RequestSpanAssert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
@ -15,11 +16,10 @@ public class SDKGeneratedDataTest {
|
|||
public void traceTreeAssertTest() {
|
||||
Config.Consumer.MAX_CONSUMER = 0;
|
||||
Span testSpan = new Span("1.0b.1465224457414.7e57f54.22905.61.2691", "", 0, "test-application", "5");
|
||||
testSpan.setViewPointId("http://hire.asiainfo.com/Aisse-Mobile-Web/aisseWorkPage/submitReimbursement");
|
||||
ContextBuffer.save(testSpan);
|
||||
TraceTreeAssert.assertEquals(new String[][]{
|
||||
{"0", "http://hire.asiainfo.com/Aisse-Mobile-Web/aisseWorkPage/submitReimbursement", null}
|
||||
});
|
||||
RequestSpan requestSpan =
|
||||
RequestSpan.RequestSpanBuilder.newBuilder(testSpan).viewPoint("http://hire.asiainfo.com/Aisse-Mobile-Web/aisseWorkPage/submitReimbursement").build();
|
||||
ContextBuffer.save(requestSpan);
|
||||
RequestSpanAssert.assertEquals(new String[][] {{"0", "http://hire.asiainfo.com/Aisse-Mobile-Web/aisseWorkPage/submitReimbursement", null}});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.ai.cloud.skywalking.protocol.common.SpanType;
|
|||
|
||||
public class SerializeTest {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
Span spandata = new Span("1.0b.1461060884539.7d6d06e.22489.1271.103", "", 0);
|
||||
Span spandata = new Span("1.0b.1461060884539.7d6d06e.22489.1271.103", "", 0, "test-application", "test");
|
||||
spandata.setSpanType(SpanType.LOCAL);
|
||||
spandata.setStartDate(System.currentTimeMillis() - 1000 * 60);
|
||||
AckSpan requestSpan = new AckSpan(spandata);
|
||||
|
|
|
|||
|
|
@ -1192,6 +1192,20 @@ public final class TraceProtocol {
|
|||
*/
|
||||
com.google.protobuf.ByteString
|
||||
getUserIdBytes();
|
||||
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
boolean hasBussinessKey();
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
java.lang.String getBussinessKey();
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
com.google.protobuf.ByteString
|
||||
getBussinessKeyBytes();
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code RequestSpan}
|
||||
|
|
@ -1302,6 +1316,12 @@ public final class TraceProtocol {
|
|||
userId_ = bs;
|
||||
break;
|
||||
}
|
||||
case 90: {
|
||||
com.google.protobuf.ByteString bs = input.readBytes();
|
||||
bitField0_ |= 0x00000400;
|
||||
bussinessKey_ = bs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
|
|
@ -1681,6 +1701,48 @@ public final class TraceProtocol {
|
|||
}
|
||||
}
|
||||
|
||||
public static final int BUSSINESSKEY_FIELD_NUMBER = 11;
|
||||
private java.lang.Object bussinessKey_;
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
public boolean hasBussinessKey() {
|
||||
return ((bitField0_ & 0x00000400) == 0x00000400);
|
||||
}
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
public java.lang.String getBussinessKey() {
|
||||
java.lang.Object ref = bussinessKey_;
|
||||
if (ref instanceof java.lang.String) {
|
||||
return (java.lang.String) ref;
|
||||
} else {
|
||||
com.google.protobuf.ByteString bs =
|
||||
(com.google.protobuf.ByteString) ref;
|
||||
java.lang.String s = bs.toStringUtf8();
|
||||
if (bs.isValidUtf8()) {
|
||||
bussinessKey_ = s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
public com.google.protobuf.ByteString
|
||||
getBussinessKeyBytes() {
|
||||
java.lang.Object ref = bussinessKey_;
|
||||
if (ref instanceof java.lang.String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(java.lang.String) ref);
|
||||
bussinessKey_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
traceId_ = "";
|
||||
parentLevel_ = "";
|
||||
|
|
@ -1692,6 +1754,7 @@ public final class TraceProtocol {
|
|||
spanType_ = 0;
|
||||
applicationId_ = "";
|
||||
userId_ = "";
|
||||
bussinessKey_ = "";
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
|
|
@ -1772,6 +1835,9 @@ public final class TraceProtocol {
|
|||
if (((bitField0_ & 0x00000200) == 0x00000200)) {
|
||||
output.writeBytes(10, getUserIdBytes());
|
||||
}
|
||||
if (((bitField0_ & 0x00000400) == 0x00000400)) {
|
||||
output.writeBytes(11, getBussinessKeyBytes());
|
||||
}
|
||||
getUnknownFields().writeTo(output);
|
||||
}
|
||||
|
||||
|
|
@ -1821,6 +1887,10 @@ public final class TraceProtocol {
|
|||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeBytesSize(10, getUserIdBytes());
|
||||
}
|
||||
if (((bitField0_ & 0x00000400) == 0x00000400)) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeBytesSize(11, getBussinessKeyBytes());
|
||||
}
|
||||
size += getUnknownFields().getSerializedSize();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
|
|
@ -1958,6 +2028,8 @@ public final class TraceProtocol {
|
|||
bitField0_ = (bitField0_ & ~0x00000100);
|
||||
userId_ = "";
|
||||
bitField0_ = (bitField0_ & ~0x00000200);
|
||||
bussinessKey_ = "";
|
||||
bitField0_ = (bitField0_ & ~0x00000400);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -2026,6 +2098,10 @@ public final class TraceProtocol {
|
|||
to_bitField0_ |= 0x00000200;
|
||||
}
|
||||
result.userId_ = userId_;
|
||||
if (((from_bitField0_ & 0x00000400) == 0x00000400)) {
|
||||
to_bitField0_ |= 0x00000400;
|
||||
}
|
||||
result.bussinessKey_ = bussinessKey_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
onBuilt();
|
||||
return result;
|
||||
|
|
@ -2086,6 +2162,11 @@ public final class TraceProtocol {
|
|||
userId_ = other.userId_;
|
||||
onChanged();
|
||||
}
|
||||
if (other.hasBussinessKey()) {
|
||||
bitField0_ |= 0x00000400;
|
||||
bussinessKey_ = other.bussinessKey_;
|
||||
onChanged();
|
||||
}
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
return this;
|
||||
}
|
||||
|
|
@ -2777,6 +2858,82 @@ public final class TraceProtocol {
|
|||
return this;
|
||||
}
|
||||
|
||||
private java.lang.Object bussinessKey_ = "";
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
public boolean hasBussinessKey() {
|
||||
return ((bitField0_ & 0x00000400) == 0x00000400);
|
||||
}
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
public java.lang.String getBussinessKey() {
|
||||
java.lang.Object ref = bussinessKey_;
|
||||
if (!(ref instanceof java.lang.String)) {
|
||||
com.google.protobuf.ByteString bs =
|
||||
(com.google.protobuf.ByteString) ref;
|
||||
java.lang.String s = bs.toStringUtf8();
|
||||
if (bs.isValidUtf8()) {
|
||||
bussinessKey_ = s;
|
||||
}
|
||||
return s;
|
||||
} else {
|
||||
return (java.lang.String) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
public com.google.protobuf.ByteString
|
||||
getBussinessKeyBytes() {
|
||||
java.lang.Object ref = bussinessKey_;
|
||||
if (ref instanceof String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8(
|
||||
(java.lang.String) ref);
|
||||
bussinessKey_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
public Builder setBussinessKey(
|
||||
java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
bitField0_ |= 0x00000400;
|
||||
bussinessKey_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
public Builder clearBussinessKey() {
|
||||
bitField0_ = (bitField0_ & ~0x00000400);
|
||||
bussinessKey_ = getDefaultInstance().getBussinessKey();
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional string bussinessKey = 11;</code>
|
||||
*/
|
||||
public Builder setBussinessKeyBytes(
|
||||
com.google.protobuf.ByteString value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
bitField0_ |= 0x00000400;
|
||||
bussinessKey_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:RequestSpan)
|
||||
}
|
||||
|
||||
|
|
@ -2810,13 +2967,14 @@ public final class TraceProtocol {
|
|||
"\n\023TraceProtocol.proto\"z\n\007AckSpan\022\017\n\007trac" +
|
||||
"eId\030\001 \002(\t\022\023\n\013parentLevel\030\002 \001(\t\022\017\n\007levelI" +
|
||||
"d\030\003 \002(\005\022\014\n\004cost\030\004 \002(\003\022\022\n\nstatusCode\030\005 \002(" +
|
||||
"\005\022\026\n\016exceptionStack\030\006 \001(\t\"\315\001\n\013RequestSpa" +
|
||||
"\005\022\026\n\016exceptionStack\030\006 \001(\t\"\343\001\n\013RequestSpa" +
|
||||
"n\022\017\n\007traceId\030\001 \002(\t\022\023\n\013parentLevel\030\002 \001(\t\022" +
|
||||
"\017\n\007levelId\030\003 \002(\005\022\023\n\013viewPointId\030\004 \002(\t\022\021\n" +
|
||||
"\tstartDate\030\005 \002(\003\022\024\n\014spanTypeDesc\030\006 \002(\t\022\020" +
|
||||
"\n\010callType\030\007 \002(\t\022\020\n\010spanType\030\010 \002(\r\022\025\n\rap" +
|
||||
"plicationId\030\t \002(\t\022\016\n\006userId\030\n \002(\tB(\n&com" +
|
||||
".ai.cloud.skywalking.protocol.proto"
|
||||
"plicationId\030\t \002(\t\022\016\n\006userId\030\n \002(\t\022\024\n\014bus" +
|
||||
"sinessKey\030\013 \001(\tB(\n&com.ai.cloud.skywalki",
|
||||
"ng.protocol.proto"
|
||||
};
|
||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
|
||||
|
|
@ -2841,7 +2999,7 @@ public final class TraceProtocol {
|
|||
internal_static_RequestSpan_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_RequestSpan_descriptor,
|
||||
new java.lang.String[] { "TraceId", "ParentLevel", "LevelId", "ViewPointId", "StartDate", "SpanTypeDesc", "CallType", "SpanType", "ApplicationId", "UserId", });
|
||||
new java.lang.String[] { "TraceId", "ParentLevel", "LevelId", "ViewPointId", "StartDate", "SpanTypeDesc", "CallType", "SpanType", "ApplicationId", "UserId", "BussinessKey", });
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(outer_class_scope)
|
||||
|
|
|
|||
|
|
@ -67,29 +67,33 @@ public class RequestSpan extends AbstractDataSerializable {
|
|||
* 用户id<br/>
|
||||
* 由授权文件指定
|
||||
*/
|
||||
private String userId;
|
||||
private String userId = "";
|
||||
|
||||
/**
|
||||
* 埋点入参列表
|
||||
*/
|
||||
private Map<String, String> paramters = new HashMap<String, String>();
|
||||
private Map<String, String> parameters = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* 业务字段
|
||||
*/
|
||||
private String businessKey = "";
|
||||
|
||||
public RequestSpan(Span spanData) {
|
||||
this.traceId = spanData.getTraceId();
|
||||
this.parentLevel = spanData.getParentLevel();
|
||||
this.levelId = spanData.getLevelId();
|
||||
this.spanType = spanData.getSpanType();
|
||||
if (isEntrySpan(spanData)) {
|
||||
this.paramters.putAll(spanData.getParameters());
|
||||
}
|
||||
this.applicationId = spanData.getApplicationId();
|
||||
this.userId = spanData.getUserId();
|
||||
}
|
||||
|
||||
public RequestSpan() {
|
||||
|
||||
}
|
||||
|
||||
private boolean isEntrySpan(Span spanData) {
|
||||
return "0".equals(spanData.getParentLevel() + spanData.getLevelId());
|
||||
private boolean isEntrySpan() {
|
||||
return "0".equals(this.getParentLevel() + this.getLevelId());
|
||||
}
|
||||
|
||||
public String getTraceId() {
|
||||
|
|
@ -172,12 +176,12 @@ public class RequestSpan extends AbstractDataSerializable {
|
|||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Map<String, String> getParamters() {
|
||||
return paramters;
|
||||
public Map<String, String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParamters(Map<String, String> paramters) {
|
||||
this.paramters = paramters;
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -188,7 +192,8 @@ public class RequestSpan extends AbstractDataSerializable {
|
|||
@Override
|
||||
public byte[] getData() {
|
||||
return TraceProtocol.RequestSpan.newBuilder().setTraceId(traceId).setParentLevel(parentLevel).setLevelId(levelId).setViewPointId(viewPointId).setStartDate(startDate)
|
||||
.setSpanType(spanType.getValue()).setSpanTypeDesc(spanTypeDesc).setCallType(callType).setApplicationId(applicationId).setUserId(userId).build().toByteArray();
|
||||
.setSpanType(spanType.getValue()).setSpanTypeDesc(spanTypeDesc).setBussinessKey(businessKey).setCallType(callType).setApplicationId(applicationId).setUserId(userId)
|
||||
.build().toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -250,6 +255,19 @@ public class RequestSpan extends AbstractDataSerializable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public RequestSpanBuilder bussinessKey(String bussinessKey) {
|
||||
ackSpan.businessKey = bussinessKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RequestSpanBuilder parameters(Map<String, String> parameters) {
|
||||
if (ackSpan.isEntrySpan()) {
|
||||
ackSpan.parameters = parameters;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public RequestSpan build() {
|
||||
return ackSpan;
|
||||
}
|
||||
|
|
@ -259,4 +277,9 @@ public class RequestSpan extends AbstractDataSerializable {
|
|||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public String getBusinessKey() {
|
||||
return businessKey;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class Span {
|
|||
* 1:异常<br/>
|
||||
* 异常判断原则:代码产生exception,并且此exception不在忽略列表中
|
||||
*/
|
||||
protected byte statusCode = 0;
|
||||
protected byte statusCode = 0;
|
||||
/**
|
||||
* 节点调用的错误堆栈<br/>
|
||||
* 堆栈以JAVA的exception为主要判断依据
|
||||
|
|
@ -60,16 +60,27 @@ public class Span {
|
|||
* 节点类型<br/>
|
||||
* 如:RPC Client,RPC Server,Local
|
||||
*/
|
||||
private SpanType spanType = SpanType.LOCAL;
|
||||
private SpanType spanType = SpanType.LOCAL;
|
||||
|
||||
public Span(String traceId) {
|
||||
/**
|
||||
* 业务字段<br/>
|
||||
*/
|
||||
private String businessKey = "";
|
||||
private String applicationId;
|
||||
private String userId;
|
||||
|
||||
public Span(String traceId, String applicationId, String userId) {
|
||||
this.traceId = traceId;
|
||||
this.applicationId = applicationId;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Span(String traceId, String parentLevel, int levelId) {
|
||||
public Span(String traceId, String parentLevel, int levelId, String applicationId, String userId) {
|
||||
this.traceId = traceId;
|
||||
this.parentLevel = parentLevel;
|
||||
this.levelId = levelId;
|
||||
this.applicationId = applicationId;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getTraceId() {
|
||||
|
|
@ -179,5 +190,31 @@ public class Span {
|
|||
}
|
||||
}
|
||||
|
||||
public String getBusinessKey() {
|
||||
return businessKey;
|
||||
}
|
||||
|
||||
public void setBusinessKey(String businessKey) {
|
||||
this.businessKey = businessKey;
|
||||
}
|
||||
|
||||
public void appendParameters(Map<String, String> parameters) {
|
||||
this.parameters.putAll(parameters);
|
||||
}
|
||||
|
||||
public String getApplicationId() {
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
public void setApplicationId(String applicationId) {
|
||||
this.applicationId = applicationId;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,4 +23,5 @@ message RequestSpan {
|
|||
required uint32 spanType = 8;
|
||||
required string applicationId = 9;
|
||||
required string userId = 10;
|
||||
optional string bussinessKey = 11;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.ai.cloud.skywalking.plugin.test.dubbo.consumer;
|
|||
|
||||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
import com.ai.cloud.skywalking.plugin.test.dubbo.interfaces.IDubboInterA;
|
||||
import com.ai.skywalking.testframework.api.TraceTreeAssert;
|
||||
import com.ai.skywalking.testframework.api.RequestSpanAssert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
|
@ -22,7 +22,7 @@ public class DubboConsumer {
|
|||
ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:consumer/dubbo-consumer.xml");
|
||||
IDubboInterA dubboInterA = context.getBean(IDubboInterA.class);
|
||||
dubboInterA.doBusiness("AAAAA");
|
||||
TraceTreeAssert.assertEquals(new String[][]{
|
||||
RequestSpanAssert.assertEquals(new String[][]{
|
||||
{"0", "dubbo://127.0.0.1:20880/com.ai.cloud.skywalking.plugin.test.dubbo.interfaces.IDubboInterA.doBusiness(String)", ""}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
|||
import com.ai.cloud.skywalking.plugin.dubbox.bugfix.below283.BugFixAcitve;
|
||||
import com.ai.cloud.skywalking.plugin.test.dubbox283.interfaces.IDubboxRestInterA;
|
||||
import com.ai.cloud.skywalking.plugin.test.dubbox283.interfaces.param.DubboxRestInterAParameter;
|
||||
import com.ai.skywalking.testframework.api.TraceTreeAssert;
|
||||
import com.ai.skywalking.testframework.api.RequestSpanAssert;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Test;
|
||||
|
|
@ -20,8 +20,7 @@ public class DubboxRestConsumer {
|
|||
|
||||
@Test
|
||||
public void test() throws InvocationTargetException, NoSuchMethodException, ClassNotFoundException, IllegalAccessException {
|
||||
TracingBootstrap
|
||||
.main(new String[]{"com.ai.cloud.skywalking.plugin.test.dubbox283.consumer.DubboxRestConsumer"});
|
||||
TracingBootstrap.main(new String[] {"com.ai.cloud.skywalking.plugin.test.dubbox283.consumer.DubboxRestConsumer"});
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException {
|
||||
|
|
@ -29,8 +28,7 @@ public class DubboxRestConsumer {
|
|||
ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:consumer/dubbox283-consumer.xml");
|
||||
IDubboxRestInterA dubboxRestInterA = context.getBean(IDubboxRestInterA.class);
|
||||
dubboxRestInterA.doBusiness(new DubboxRestInterAParameter("AAAAA"));
|
||||
TraceTreeAssert.assertEquals(new String[][]{
|
||||
{"0", "rest://127.0.0.1:20880/com.ai.cloud.skywalking.plugin.test.dubbox283.interfaces.IDubboxRestInterA.doBusiness(DubboxRestInterAParameter)", ""}
|
||||
});
|
||||
RequestSpanAssert.assertEquals(new String[][] {
|
||||
{"0", "rest://127.0.0.1:20880/com.ai.cloud.skywalking.plugin.test.dubbox283.interfaces.IDubboxRestInterA.doBusiness(DubboxRestInterAParameter)", ""}});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.ai.cloud.skywalking.plugin.test.dubbox284.consumer;
|
|||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
import com.ai.cloud.skywalking.plugin.test.dubbox283.interfaces.param.DubboxRestInterAParameter;
|
||||
import com.ai.cloud.skywalking.plugin.test.dubbox284.interfaces.IDubboxRestInterA;
|
||||
import com.ai.skywalking.testframework.api.TraceTreeAssert;
|
||||
import com.ai.skywalking.testframework.api.RequestSpanAssert;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Test;
|
||||
|
|
@ -19,16 +19,14 @@ public class DubboxRestConsumer {
|
|||
|
||||
@Test
|
||||
public void test() throws InvocationTargetException, NoSuchMethodException, ClassNotFoundException, IllegalAccessException {
|
||||
TracingBootstrap
|
||||
.main(new String[]{"com.ai.cloud.skywalking.plugin.test.dubbox284.consumer.DubboxRestConsumer"});
|
||||
TracingBootstrap.main(new String[] {"com.ai.cloud.skywalking.plugin.test.dubbox284.consumer.DubboxRestConsumer"});
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:consumer/dubbox284-consumer.xml");
|
||||
IDubboxRestInterA dubboxRestInterA = context.getBean(IDubboxRestInterA.class);
|
||||
dubboxRestInterA.doBusiness(new DubboxRestInterAParameter("AAAAA"));
|
||||
TraceTreeAssert.assertEquals(new String[][]{
|
||||
{"0", "rest://127.0.0.1:20880/com.ai.cloud.skywalking.plugin.test.dubbox284.interfaces.IDubboxRestInterA.doBusiness(DubboxRestInterAParameter)", ""}
|
||||
});
|
||||
RequestSpanAssert.assertEquals(new String[][] {
|
||||
{"0", "rest://127.0.0.1:20880/com.ai.cloud.skywalking.plugin.test.dubbox284.interfaces.IDubboxRestInterA.doBusiness(DubboxRestInterAParameter)", ""}});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
<version>4.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!--
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
package org.skywalking.httpClient.v4.plugin;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
import com.ai.skywalking.testframework.api.RequestSpanAssert;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
|
|
@ -15,50 +10,50 @@ import org.apache.http.client.methods.HttpGet;
|
|||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class TestHttpClientV42 {
|
||||
@Test
|
||||
public void testsql() throws IllegalAccessException,
|
||||
IllegalArgumentException, InvocationTargetException,
|
||||
NoSuchMethodException, SecurityException, ClassNotFoundException {
|
||||
TracingBootstrap
|
||||
.main(new String[] { "org.skywalking.httpClient.v4.plugin.TestHttpClientV42" });
|
||||
}
|
||||
@Test
|
||||
public void testsql() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException {
|
||||
TracingBootstrap.main(new String[] {"org.skywalking.httpClient.v4.plugin.TestHttpClientV42"});
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ClassNotFoundException,
|
||||
SQLException, InterruptedException, ClientProtocolException,
|
||||
IOException {
|
||||
// 默认的client类。
|
||||
HttpClient client = new DefaultHttpClient();
|
||||
// 设置为get取连接的方式.
|
||||
HttpGet get = new HttpGet("http://www.baidu.com");
|
||||
try {
|
||||
// 得到返回的response.
|
||||
HttpResponse response = client.execute(get);
|
||||
// 得到返回的client里面的实体对象信息.
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null) {
|
||||
System.out.println("内容编码是:" + entity.getContentEncoding());
|
||||
System.out.println("内容类型是:" + entity.getContentType());
|
||||
// 得到返回的主体内容.
|
||||
InputStream instream = entity.getContent();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(instream, "UTF-8"));
|
||||
System.out.println(reader.readLine());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
instream.close();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.getConnectionManager().shutdown();
|
||||
}
|
||||
public static void main(String[] args) throws ClassNotFoundException, SQLException, InterruptedException, ClientProtocolException, IOException {
|
||||
// 默认的client类。
|
||||
HttpClient client = new DefaultHttpClient();
|
||||
// 设置为get取连接的方式.
|
||||
HttpGet get = new HttpGet("http://www.baidu.com");
|
||||
try {
|
||||
// 得到返回的response.
|
||||
HttpResponse response = client.execute(get);
|
||||
// 得到返回的client里面的实体对象信息.
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null) {
|
||||
System.out.println("内容编码是:" + entity.getContentEncoding());
|
||||
System.out.println("内容类型是:" + entity.getContentType());
|
||||
// 得到返回的主体内容.
|
||||
InputStream instream = entity.getContent();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(instream, "UTF-8"));
|
||||
System.out.println(reader.readLine());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
instream.close();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.getConnectionManager().shutdown();
|
||||
}
|
||||
|
||||
Thread.sleep(5 * 1000);
|
||||
}
|
||||
RequestSpanAssert.assertEquals(new String[][] {{"0", "http://www.baidu.com", ""}});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
package org.skywalking.httpClient.v4.plugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
import com.ai.skywalking.testframework.api.RequestSpanAssert;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
|
|
@ -12,49 +10,45 @@ import org.apache.http.impl.client.HttpClientBuilder;
|
|||
import org.apache.http.util.EntityUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class TestHttpClientV43 {
|
||||
@Test
|
||||
public void testsql() throws IllegalAccessException,
|
||||
IllegalArgumentException, InvocationTargetException,
|
||||
NoSuchMethodException, SecurityException, ClassNotFoundException {
|
||||
TracingBootstrap
|
||||
.main(new String[] { "org.skywalking.httpClient.v4.plugin.TestHttpClientV43" });
|
||||
}
|
||||
@Test
|
||||
public void testsql() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException {
|
||||
TracingBootstrap.main(new String[] {"org.skywalking.httpClient.v4.plugin.TestHttpClientV43"});
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ClassNotFoundException,
|
||||
SQLException, InterruptedException {
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
// HttpClient
|
||||
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
|
||||
public static void main(String[] args) throws ClassNotFoundException, SQLException, InterruptedException {
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
// HttpClient
|
||||
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://www.baidu.com");
|
||||
System.out.println(httpGet.getRequestLine());
|
||||
try {
|
||||
// 执行get请求
|
||||
HttpResponse httpResponse = closeableHttpClient.execute(httpGet);
|
||||
// 获取响应消息实体
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
// 响应状态
|
||||
System.out.println("status:" + httpResponse.getStatusLine());
|
||||
// 判断响应实体是否为空
|
||||
if (entity != null) {
|
||||
System.out.println("contentEncoding:"
|
||||
+ entity.getContentEncoding());
|
||||
System.out.println("response content:"
|
||||
+ EntityUtils.toString(entity));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try { // 关闭流并释放资源
|
||||
closeableHttpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Thread.sleep(5*1000);
|
||||
}
|
||||
HttpGet httpGet = new HttpGet("http://www.baidu.com");
|
||||
System.out.println(httpGet.getRequestLine());
|
||||
try {
|
||||
// 执行get请求
|
||||
HttpResponse httpResponse = closeableHttpClient.execute(httpGet);
|
||||
// 获取响应消息实体
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
// 响应状态
|
||||
System.out.println("status:" + httpResponse.getStatusLine());
|
||||
// 判断响应实体是否为空
|
||||
if (entity != null) {
|
||||
System.out.println("contentEncoding:" + entity.getContentEncoding());
|
||||
System.out.println("response content:" + EntityUtils.toString(entity));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try { // 关闭流并释放资源
|
||||
closeableHttpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
RequestSpanAssert.assertEquals(new String[][] {{"0", "http://www.baidu.com", ""}});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ skywalking.application_code=test
|
|||
skywalking.auth_system_env_name=SKYWALKING_RUN
|
||||
#skywalking数据编码
|
||||
skywalking.charset=UTF-8
|
||||
skywalking.auth_override=true
|
||||
|
||||
#是否打印数据
|
||||
buriedpoint.printf=true
|
||||
|
|
@ -27,11 +28,8 @@ sender.max_send_length=20000
|
|||
#当没有Sender时,尝试获取sender的等待周期
|
||||
sender.retry_get_sender_wait_interval=2000
|
||||
|
||||
|
||||
|
||||
|
||||
#最大消费线程数
|
||||
consumer.max_consumer=2
|
||||
consumer.max_consumer=0
|
||||
#消费者最大等待时间
|
||||
consumer.max_wait_time=5
|
||||
#发送失败等待时间
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@ import java.sql.Driver;
|
|||
import java.sql.DriverManager;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.ai.cloud.skywalking.logging.LogManager;
|
||||
import com.ai.cloud.skywalking.logging.Logger;
|
||||
import com.ai.cloud.skywalking.plugin.boot.BootException;
|
||||
import com.ai.cloud.skywalking.plugin.boot.BootPluginDefine;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package com.ai.cloud.skywalking.plugin.jdbc;
|
||||
|
||||
import com.ai.cloud.skywalking.conf.AuthDesc;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import com.ai.cloud.skywalking.logging.LogManager;
|
||||
import com.ai.cloud.skywalking.logging.Logger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
|
@ -11,10 +12,9 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class TracingDriver implements Driver {
|
||||
private static org.apache.logging.log4j.Logger logger = LogManager.getLogger(TracingDriver.class);
|
||||
private static Logger logger = LogManager.getLogger(TracingDriver.class);
|
||||
|
||||
private static final String TRACING_SIGN = "tracing:";
|
||||
|
||||
|
|
@ -34,8 +34,7 @@ public class TracingDriver implements Driver {
|
|||
}
|
||||
}
|
||||
|
||||
public java.sql.Connection connect(String url, Properties info)
|
||||
throws SQLException {
|
||||
public java.sql.Connection connect(String url, Properties info) throws SQLException {
|
||||
Driver driver = DriverChooser.choose(convertConnectURLIfNecessary(url));
|
||||
if (driver == null) {
|
||||
throw new SQLException("Failed to choose driver by url[{}].", convertConnectURLIfNecessary(url));
|
||||
|
|
@ -60,8 +59,7 @@ public class TracingDriver implements Driver {
|
|||
return driver.acceptsURL(convertConnectURLIfNecessary(url));
|
||||
}
|
||||
|
||||
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
|
||||
throws SQLException {
|
||||
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
|
||||
return DriverChooser.choose(convertConnectURLIfNecessary(url)).
|
||||
getPropertyInfo(convertConnectURLIfNecessary(url), info);
|
||||
}
|
||||
|
|
@ -78,12 +76,12 @@ public class TracingDriver implements Driver {
|
|||
return false;
|
||||
}
|
||||
|
||||
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
|
||||
public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
|
||||
return null;
|
||||
}
|
||||
|
||||
static class DriverChooser {
|
||||
private static org.apache.logging.log4j.Logger logger = LogManager.getLogger(DriverChooser.class);
|
||||
private static Logger logger = LogManager.getLogger(DriverChooser.class);
|
||||
|
||||
private static Map<String, String> urlDriverMapping = new HashMap<String, String>();
|
||||
|
||||
|
|
@ -98,7 +96,7 @@ public class TracingDriver implements Driver {
|
|||
Class<?> driverClass = Class.forName(driverClassStr);
|
||||
driver = (Driver) driverClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to initial Driver class {}.", driverClassStr, e);
|
||||
logger.error("Failed to initial Driver class {}.", new Object[] {driverClassStr}, e);
|
||||
}
|
||||
|
||||
return driver;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package test.ai.cloud.skywalking.plugin.mysql;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
import com.ai.skywalking.testframework.api.TraceTreeAssert;
|
||||
import com.ai.skywalking.testframework.api.RequestSpanAssert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
|
@ -13,17 +13,13 @@ import java.sql.SQLException;
|
|||
public class MysqlJDBCTest {
|
||||
|
||||
@Test
|
||||
public void testMySqlJDBC() throws InvocationTargetException,
|
||||
NoSuchMethodException, ClassNotFoundException,
|
||||
IllegalAccessException {
|
||||
TracingBootstrap
|
||||
.main(new String[]{"test.ai.cloud.skywalking.plugin.mysql.MysqlJDBCTest"});
|
||||
public void testMySqlJDBC() throws InvocationTargetException, NoSuchMethodException, ClassNotFoundException, IllegalAccessException {
|
||||
TracingBootstrap.main(new String[] {"test.ai.cloud.skywalking.plugin.mysql.MysqlJDBCTest"});
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ClassNotFoundException,
|
||||
SQLException, InterruptedException {
|
||||
public static void main(String[] args) throws ClassNotFoundException, SQLException, InterruptedException {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
String url = "tracing:jdbc:mysql://10.1.241.20:31306/sw_db?user=sw_dbusr01&password=sw_dbusr01";
|
||||
String url = "tracing:jdbc:mysql://127.0.0.1:3306/test?user=root&password=root";
|
||||
Connection con = DriverManager.getConnection(url);
|
||||
con.setAutoCommit(false);
|
||||
|
||||
|
|
@ -32,11 +28,10 @@ public class MysqlJDBCTest {
|
|||
p0.execute();
|
||||
con.commit();
|
||||
con.close();
|
||||
TraceTreeAssert.assertEquals(new String[][]{
|
||||
{"0", "jdbc:mysql://10.1.241.20:31306/sw_db?user=sw_dbusr01&password=sw_dbusr01(null)", "preaparedStatement.executeUpdate:select 1 from dual where 1=?"},
|
||||
{"0", "jdbc:mysql://10.1.241.20:31306/sw_db?user=sw_dbusr01&password=sw_dbusr01(null)", "connection.commit"},
|
||||
{"0", "jdbc:mysql://10.1.241.20:31306/sw_db?user=sw_dbusr01&password=sw_dbusr01(null)", "connection.close"},
|
||||
}, true);
|
||||
RequestSpanAssert.assertEquals(
|
||||
new String[][] {{"0", "jdbc:mysql://127.0.0.1:3306/test?user=root&password=root(null)", "preaparedStatement.executeUpdate:select 1 from dual where 1=?"},
|
||||
{"0", "jdbc:mysql://127.0.0.1:3306/test?user=root&password=root(null)", "connection.commit"},
|
||||
{"0", "jdbc:mysql://127.0.0.1:3306/test?user=root&password=root(null)", "connection.close"},}, true);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package test.ai.cloud.skywalking.plugin.oracle;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
import com.ai.skywalking.testframework.api.TraceTreeAssert;
|
||||
import com.ai.skywalking.testframework.api.RequestSpanAssert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
|
@ -35,7 +35,7 @@ public class OracleJDBCTest {
|
|||
p0.execute();
|
||||
con.commit();
|
||||
con.close();
|
||||
TraceTreeAssert.assertEquals(new String[][]{
|
||||
RequestSpanAssert.assertEquals(new String[][]{
|
||||
{"0", "jdbc:oracle:thin:@10.1.130.239:1521:ora(edc_export)", "preaparedStatement.executeUpdate:select 1 from dual where 1=?"},
|
||||
{"0", "jdbc:oracle:thin:@10.1.130.239:1521:ora(edc_export)", "connection.commit"},
|
||||
{"0", "jdbc:oracle:thin:@10.1.130.239:1521:ora(edc_export)", "connection.close"},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.ai.cloud.skywalking.jedis.v2.plugin;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
import com.ai.skywalking.testframework.api.TraceTreeAssert;
|
||||
import com.ai.skywalking.testframework.api.RequestSpanAssert;
|
||||
import org.junit.Test;
|
||||
import redis.clients.jedis.HostAndPort;
|
||||
import redis.clients.jedis.JedisCluster;
|
||||
|
|
@ -13,22 +13,16 @@ import java.util.Set;
|
|||
|
||||
public class JedisClusterTest {
|
||||
@Test
|
||||
public void test() throws IllegalAccessException, IllegalArgumentException,
|
||||
InvocationTargetException, NoSuchMethodException,
|
||||
SecurityException, ClassNotFoundException {
|
||||
TracingBootstrap
|
||||
.main(new String[]{"com.ai.cloud.skywalking.jedis.v2.plugin.JedisClusterTest"});
|
||||
public void test() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException {
|
||||
TracingBootstrap.main(new String[] {"com.ai.cloud.skywalking.jedis.v2.plugin.JedisClusterTest"});
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ClassNotFoundException,
|
||||
SQLException, InterruptedException {
|
||||
public static void main(String[] args) throws ClassNotFoundException, SQLException, InterruptedException {
|
||||
JedisCluster jedisCluster = new JedisCluster(getHostAndPorts());
|
||||
jedisCluster.set("11111", "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111");
|
||||
TraceTreeAssert.assertEquals(new String[][]{
|
||||
RequestSpanAssert.assertEquals(new String[][] {
|
||||
// 根据实际情况进行修改
|
||||
{"0.0", "127.0.0.1:7001 set", "key=11111"},
|
||||
{"0", "127.0.0.1:7002;127.0.0.1:7001;127.0.0.1:7000;127.0.0.1:7005;127.0.0.1:7004;127.0.0.1:7003; set", "key=11111"},
|
||||
});
|
||||
{"0.0", "127.0.0.1:7001 set", "key=11111"}, {"0", "127.0.0.1:7002;127.0.0.1:7001;127.0.0.1:7000;127.0.0.1:7005;127.0.0.1:7004;127.0.0.1:7003; set", "key=11111"},});
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,41 +1,33 @@
|
|||
package com.ai.cloud.skywalking.jedis.v2.plugin;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
import com.ai.skywalking.testframework.api.RequestSpanAssert;
|
||||
import org.junit.Test;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.ai.skywalking.testframework.api.TraceTreeAssert;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import com.ai.cloud.skywalking.plugin.TracingBootstrap;
|
||||
|
||||
public class JedisTest {
|
||||
@Test
|
||||
public void test() throws IllegalAccessException, IllegalArgumentException,
|
||||
InvocationTargetException, NoSuchMethodException,
|
||||
SecurityException, ClassNotFoundException {
|
||||
TracingBootstrap
|
||||
.main(new String[] { "com.ai.cloud.skywalking.jedis.v2.plugin.JedisTest" });
|
||||
}
|
||||
@Test
|
||||
public void test() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException {
|
||||
TracingBootstrap.main(new String[] {"com.ai.cloud.skywalking.jedis.v2.plugin.JedisTest"});
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ClassNotFoundException,
|
||||
SQLException, InterruptedException {
|
||||
Jedis jedis = null;
|
||||
try{
|
||||
jedis = new Jedis("127.0.0.1", 6379);
|
||||
jedis.set("11111", "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111");
|
||||
TraceTreeAssert.assertEquals(new String[][]{
|
||||
{"0", "127.0.0.1:6379 set", "key=11111"},
|
||||
});
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testNormal() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, InterruptedException{
|
||||
JedisTest.main(null);
|
||||
}
|
||||
public static void main(String[] args) throws ClassNotFoundException, SQLException, InterruptedException {
|
||||
Jedis jedis = null;
|
||||
try {
|
||||
jedis = new Jedis("127.0.0.1", 6379);
|
||||
jedis.set("11111", "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111");
|
||||
RequestSpanAssert.assertEquals(new String[][] {{"0", "127.0.0.1:6379 set", "key=11111"},});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testNormal() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, InterruptedException {
|
||||
JedisTest.main(null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ai.skywalking.testframework.api;
|
||||
|
||||
import com.ai.cloud.skywalking.protocol.Span;
|
||||
import com.ai.cloud.skywalking.protocol.common.ISerializable;
|
||||
import com.ai.skywalking.testframework.api.config.Config;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
|
@ -8,13 +8,13 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class ContextPoolOperator {
|
||||
public static List<Span> acquireSpanData() {
|
||||
List<Span> resultSpan = new ArrayList<Span>();
|
||||
public static List<ISerializable> acquireBufferData() {
|
||||
List<ISerializable> resultSpan = new ArrayList<ISerializable>();
|
||||
Object[] bufferGroupObjectArray = acquireBufferGroupObjectArrayByClassLoader();
|
||||
|
||||
for (Object bufferGroup : bufferGroupObjectArray) {
|
||||
Span[] spanList = acquireSpanData(bufferGroup);
|
||||
for (Span span : spanList) {
|
||||
ISerializable[] spanList = acquireBufferData(bufferGroup);
|
||||
for (ISerializable span : spanList) {
|
||||
if (span != null) {
|
||||
resultSpan.add(span);
|
||||
}
|
||||
|
|
@ -28,20 +28,19 @@ public class ContextPoolOperator {
|
|||
Object[] bufferGroupObjectArray = acquireBufferGroupObjectArrayByClassLoader();
|
||||
|
||||
for (Object bufferGroup : bufferGroupObjectArray) {
|
||||
Span[] spanList = acquireSpanData(bufferGroup);
|
||||
ISerializable[] spanList = acquireBufferData(bufferGroup);
|
||||
for (int i = 0; i < spanList.length; i++) {
|
||||
spanList[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Span[] acquireSpanData(Object bufferGroup) {
|
||||
private static ISerializable[] acquireBufferData(Object bufferGroup) {
|
||||
try {
|
||||
Class bufferGroupClass = Thread.currentThread().getContextClassLoader()
|
||||
.loadClass(Config.BUFFER_GROUP_CLASS_NAME);
|
||||
Class bufferGroupClass = Thread.currentThread().getContextClassLoader().loadClass(Config.BUFFER_GROUP_CLASS_NAME);
|
||||
Field spanArrayField = bufferGroupClass.getDeclaredField(Config.SPAN_ARRAY_FIELD_NAME);
|
||||
spanArrayField.setAccessible(true);
|
||||
return (Span[]) spanArrayField.get(bufferGroup);
|
||||
return (ISerializable[]) spanArrayField.get(bufferGroup);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to acquire span array", e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ai.skywalking.testframework.api;
|
||||
|
||||
import com.ai.cloud.skywalking.protocol.Span;
|
||||
import com.ai.cloud.skywalking.protocol.RequestSpan;
|
||||
import com.ai.cloud.skywalking.protocol.common.ISerializable;
|
||||
import com.ai.skywalking.testframework.api.exception.SpanDataFormatException;
|
||||
import com.ai.skywalking.testframework.api.exception.SpanDataNotEqualsException;
|
||||
import com.ai.skywalking.testframework.api.exception.TraceIdNotSameException;
|
||||
|
|
@ -9,40 +10,53 @@ import com.ai.skywalking.testframework.api.exception.TraceNodeSizeNotEqualExcept
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TraceTreeAssert {
|
||||
public class RequestSpanAssert {
|
||||
|
||||
public static void assertEquals(String[][] expectedTraceTree) {
|
||||
assertEquals(expectedTraceTree, false);
|
||||
public static void assertEquals(String[][] expectedRequestSpan) {
|
||||
assertEquals(expectedRequestSpan, false);
|
||||
}
|
||||
|
||||
public static void assertEquals(String[][] expectedTraceTree, boolean skipValidateTraceId) {
|
||||
List<Span> spanDataInBuffer = ContextPoolOperator.acquireSpanData();
|
||||
public static void assertEquals(String[][] expectedRequestSpan, boolean skipValidateTraceId) {
|
||||
List<RequestSpan> requestSpan = acquiredRequestSpanFromBuffer();
|
||||
|
||||
if (!skipValidateTraceId) {
|
||||
validateTraceId(spanDataInBuffer);
|
||||
validateTraceId(requestSpan);
|
||||
}
|
||||
|
||||
List<String> assertSpanData = convertSpanDataToCompareStr(spanDataInBuffer);
|
||||
List<String> assertSpanData = convertSpanDataToCompareStr(requestSpan);
|
||||
|
||||
List<String> expectedSpanData = convertSpanDataToCompareStr(expectedTraceTree);
|
||||
List<String> expectedSpanData = convertSpanDataToCompareStr(expectedRequestSpan);
|
||||
|
||||
validateTraceSpanSize(expectedSpanData.size(), assertSpanData.size());
|
||||
|
||||
validateSpanData(expectedSpanData, assertSpanData);
|
||||
|
||||
}
|
||||
|
||||
private static List<RequestSpan> acquiredRequestSpanFromBuffer() {
|
||||
List<ISerializable> spans = ContextPoolOperator.acquireBufferData();
|
||||
|
||||
List<RequestSpan> result = new ArrayList<RequestSpan>();
|
||||
for (ISerializable span : spans) {
|
||||
if (span instanceof RequestSpan) {
|
||||
result.add((RequestSpan) span);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void clearTraceData() {
|
||||
ContextPoolOperator.clearSpanData();
|
||||
}
|
||||
|
||||
private static List<String> convertSpanDataToCompareStr(List<Span> assertSpanData) {
|
||||
private static List<String> convertSpanDataToCompareStr(List<RequestSpan> assertSpanData) {
|
||||
List<String> resultSpanData = new ArrayList<String>();
|
||||
for (Span span : assertSpanData) {
|
||||
for (RequestSpan span : assertSpanData) {
|
||||
StringBuffer tmpSpanDataStr = new StringBuffer(jointTraceLevelId(span.getParentLevel(), span.getLevelId() + " "));
|
||||
tmpSpanDataStr.append(span.getViewPointId().trim() + " ")
|
||||
.append(span.getBusinessKey().trim() + " ");
|
||||
tmpSpanDataStr.append(span.getViewPointId().trim() + " ");
|
||||
tmpSpanDataStr.append(span.getBusinessKey() == null ? " " : span.getBusinessKey() + " ");
|
||||
|
||||
resultSpanData.add(tmpSpanDataStr.toString());
|
||||
resultSpanData.add(tmpSpanDataStr.toString().trim());
|
||||
}
|
||||
return resultSpanData;
|
||||
}
|
||||
|
|
@ -60,15 +74,13 @@ public class TraceTreeAssert {
|
|||
List<String> resultSpanData = new ArrayList<String>();
|
||||
for (String[] spanDataArray : assertTraceTree) {
|
||||
if (spanDataArray.length != 3) {
|
||||
throw new SpanDataFormatException("assert trace tree is illegal, " +
|
||||
"Format :\ttraceLevelId\t|\tviewPoint\t|\tbusinesskey");
|
||||
throw new SpanDataFormatException("assert trace tree is illegal, " + "Format :\ttraceLevelId\t|\tviewPoint\t|\tbusinesskey");
|
||||
}
|
||||
|
||||
StringBuffer tmpSpanDataStr = new StringBuffer(spanDataArray[0] + " ");
|
||||
tmpSpanDataStr.append(spanDataArray[1] == null ? " " : spanDataArray[1].trim() + " ")
|
||||
.append(spanDataArray[2] == null ? " " : spanDataArray[2].trim() + " ");
|
||||
tmpSpanDataStr.append(spanDataArray[1] == null ? " " : spanDataArray[1].trim() + " ").append(spanDataArray[2] == null ? " " : spanDataArray[2].trim() + " ");
|
||||
|
||||
resultSpanData.add(tmpSpanDataStr.toString());
|
||||
resultSpanData.add(tmpSpanDataStr.toString().trim());
|
||||
}
|
||||
|
||||
return resultSpanData;
|
||||
|
|
@ -100,9 +112,9 @@ public class TraceTreeAssert {
|
|||
|
||||
}
|
||||
|
||||
private static void validateTraceId(List<Span> traceSpanList) {
|
||||
private static void validateTraceId(List<RequestSpan> traceSpanList) {
|
||||
String traceId = null;
|
||||
for (Span span : traceSpanList) {
|
||||
for (RequestSpan span : traceSpanList) {
|
||||
if (traceId == null) {
|
||||
traceId = span.getTraceId();
|
||||
}
|
||||
Loading…
Reference in New Issue