diff --git a/pom.xml b/pom.xml
index e5a2603454..f0810c314f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -155,17 +155,4 @@
-
-
-
-
- false
-
- bintray
- bintray
- https://jcenter.bintray.com
-
-
-
-
diff --git a/skywalking-collector/pom.xml b/skywalking-collector/pom.xml
index 46a96c2940..0a0453660f 100644
--- a/skywalking-collector/pom.xml
+++ b/skywalking-collector/pom.xml
@@ -5,7 +5,6 @@
skywalking-collector-cluster
skywalking-collector-worker
- ../skywalking-collector-actor
skywalking-collector-actor
diff --git a/skywalking-collector/skywalking-collector-actor/src/test/java/com/a/eye/skywalking/collector/actor/AbstractWorkerProviderTestCase.java b/skywalking-collector/skywalking-collector-actor/src/test/java/com/a/eye/skywalking/collector/actor/AbstractWorkerProviderTestCase.java
new file mode 100644
index 0000000000..a465dc393d
--- /dev/null
+++ b/skywalking-collector/skywalking-collector-actor/src/test/java/com/a/eye/skywalking/collector/actor/AbstractWorkerProviderTestCase.java
@@ -0,0 +1,46 @@
+package com.a.eye.skywalking.collector.actor;
+
+import akka.actor.ActorSystem;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Created by wusheng on 2017/2/24.
+ */
+public class AbstractWorkerProviderTestCase {
+
+
+ ActorSystem system;
+
+ @Before
+ public void createSystem() {
+ system = ActorSystem.create();
+ }
+
+ @After
+ public void terminateSystem() throws IllegalAccessException {
+ system.terminate();
+ system.awaitTermination();
+ system = null;
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testCreateWorker(){
+ AbstractWorkerProvider aWorkerProvider = new AbstractWorkerProvider() {
+ @Override public String workerName() {
+ return null;
+ }
+
+ @Override public Class workerClass() {
+ return Object.class;
+ }
+
+ @Override public int workerNum() {
+ return 1;
+ }
+ };
+
+ aWorkerProvider.createWorker(system);
+ }
+}
diff --git a/skywalking-collector/skywalking-collector-actor/src/test/java/com/a/eye/skywalking/collector/actor/SpiTestWorkerFactoryTestCase.java b/skywalking-collector/skywalking-collector-actor/src/test/java/com/a/eye/skywalking/collector/actor/SpiTestWorkerFactoryTestCase.java
index 5b3ed571ac..49bb9dd82a 100644
--- a/skywalking-collector/skywalking-collector-actor/src/test/java/com/a/eye/skywalking/collector/actor/SpiTestWorkerFactoryTestCase.java
+++ b/skywalking-collector/skywalking-collector-actor/src/test/java/com/a/eye/skywalking/collector/actor/SpiTestWorkerFactoryTestCase.java
@@ -27,6 +27,8 @@ public class SpiTestWorkerFactoryTestCase {
@Test
public void testWorkerCreate() {
+
+
SpiTestWorkerFactory factory = Mockito.mock(SpiTestWorkerFactory.class);
Mockito.when(factory.workerName()).thenReturn("");
factory.createWorker(system);
diff --git a/skywalking-commons/skywalking-trace/pom.xml b/skywalking-commons/skywalking-trace/pom.xml
index f640eae311..de9c8ae63e 100644
--- a/skywalking-commons/skywalking-trace/pom.xml
+++ b/skywalking-commons/skywalking-trace/pom.xml
@@ -17,5 +17,68 @@
skywalking-logging-api
${project.version}
+
+ com.a.eye
+ skywalking-util
+ ${project.version}
+
+
+
+ com.google.protobuf
+ protobuf-java
+ 3.0.0
+
+
+
+
+
+ kr.motd.maven
+ os-maven-plugin
+ 1.5.0.Final
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.0.0
+
+
+ add-source
+ generate-sources
+
+ add-source
+
+
+
+ src/java/generated-source/protobuf/java
+
+
+
+
+
+
+
+ org.xolstice.maven.plugins
+ protobuf-maven-plugin
+ 0.5.0
+
+ com.google.protobuf:protoc:3.0.0:exe:${os.detected.classifier}
+
+ grpc-java
+ io.grpc:protoc-gen-grpc-java:1.0.2:exe:${os.detected.classifier}
+
+
+
+
+
+ compile
+ compile-custom
+
+
+
+
+
+
diff --git a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/messages/ISerializable.java b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/messages/ISerializable.java
new file mode 100644
index 0000000000..25896c30a4
--- /dev/null
+++ b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/messages/ISerializable.java
@@ -0,0 +1,29 @@
+package com.a.eye.skywalking.messages;
+
+import com.a.eye.skywalking.trace.TraceSegment;
+
+/**
+ * All messages, which need to send between Akka actors, should implement this interface.
+ * The whole {@link TraceSegment} supports this.
+ *
+ * T should be a protobuf Object, which is generated by protoc.
+ * {@see /sky-walking/skywalking-commons/skywalking-trace/src/main/proto/trace.proto}
+ *
+ * {@see https://github.com/google/protobuf/tree/master/java}
+ *
+ * Created by wusheng on 2017/2/22.
+ */
+public interface ISerializable {
+ /**
+ * Serialize this object to T
+ * @return
+ */
+ T serialize();
+
+ /**
+ * Initialize this object by the given message.
+ *
+ * @param message to init object.
+ */
+ void deserialize(T message);
+}
diff --git a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/LogData.java b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/LogData.java
index 576aa680c0..24e6a42ef6 100644
--- a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/LogData.java
+++ b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/LogData.java
@@ -1,6 +1,12 @@
package com.a.eye.skywalking.trace;
+import com.a.eye.skywalking.api.util.StringUtil;
+import com.a.eye.skywalking.messages.ISerializable;
+import com.a.eye.skywalking.trace.messages.proto.KeyValue;
+import com.a.eye.skywalking.trace.messages.proto.LogDataMessage;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -8,15 +14,22 @@ import java.util.Map;
*
* Created by wusheng on 2017/2/17.
*/
-public class LogData {
- private final long time;
- private final Map fields;
+public class LogData implements ISerializable{
+ private long time;
+ private Map fields;
LogData(long time, Map fields) {
this.time = time;
+ if(fields == null){
+ throw new NullPointerException();
+ }
this.fields = fields;
}
+ LogData(LogDataMessage message){
+ deserialize(message);
+ }
+
public long getTime() {
return time;
}
@@ -24,4 +37,38 @@ public class LogData {
public Map getFields() {
return Collections.unmodifiableMap(fields);
}
+
+ @Override
+ public LogDataMessage serialize() {
+ LogDataMessage.Builder logDataBuilder = LogDataMessage.newBuilder();
+ logDataBuilder.setTime(time);
+
+ if(fields != null){
+ for (Map.Entry entry : fields.entrySet()) {
+ KeyValue.Builder logEntryBuilder = KeyValue.newBuilder();
+
+ logEntryBuilder.setKey(entry.getKey());
+ String value = String.valueOf(entry.getValue());
+ if(!StringUtil.isEmpty(value)) {
+ logEntryBuilder.setValue(value);
+ }
+
+ logDataBuilder.addFields(logEntryBuilder);
+ }
+ }
+ return logDataBuilder.build();
+ }
+
+ @Override
+ public void deserialize(LogDataMessage message) {
+ time = message.getTime();
+ List list = message.getFieldsList();
+ if(list != null){
+ HashMap initFields = new HashMap();
+ for (KeyValue field : list) {
+ initFields.put(field.getKey(), field.getValue());
+ }
+ this.fields = initFields;
+ }
+ }
}
diff --git a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/Span.java b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/Span.java
index 75e7f3ab62..51f28adcee 100644
--- a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/Span.java
+++ b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/Span.java
@@ -1,10 +1,16 @@
package com.a.eye.skywalking.trace;
+import com.a.eye.skywalking.api.util.StringUtil;
+import com.a.eye.skywalking.messages.ISerializable;
+import com.a.eye.skywalking.trace.messages.proto.KeyValue;
+import com.a.eye.skywalking.trace.messages.proto.LogDataMessage;
+import com.a.eye.skywalking.trace.messages.proto.SpanMessage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -17,7 +23,7 @@ import java.util.Map;
*
* Created by wusheng on 2017/2/17.
*/
-public class Span {
+public class Span implements ISerializable {
private int spanId;
private int parentSpanId;
@@ -54,7 +60,7 @@ public class Span {
private final List logs;
/**
- * Create a new span, by given span id and parent span id.
+ * Create a new span, by given span id, parent span id and operationName.
* This span must belong a {@link TraceSegment}, also is a part of Distributed Trace.
*
* @param spanId given by the creator, and must be unique id in the {@link TraceSegment}
@@ -63,9 +69,23 @@ public class Span {
* @param operationName {@link #operationName}
*/
private Span(int spanId, int parentSpanId, String operationName) {
+ this(spanId, parentSpanId, operationName, System.currentTimeMillis());
+ }
+
+ /**
+ * Create a new span, by given span id, parent span id, operationName and startTime.
+ * This span must belong a {@link TraceSegment}, also is a part of Distributed Trace.
+ *
+ * @param spanId given by the creator, and must be unique id in the {@link TraceSegment}
+ * @param parentSpanId given by the creator, and must be an existed span id in the {@link TraceSegment}. Value -1
+ * means no parent span if this {@link TraceSegment}.
+ * @param operationName {@link #operationName}
+ * @param startTime given start timestamp.
+ */
+ private Span(int spanId, int parentSpanId, String operationName, long startTime) {
this.spanId = spanId;
this.parentSpanId = parentSpanId;
- this.startTime = System.currentTimeMillis();
+ this.startTime = startTime;
this.operationName = operationName;
this.tags = new HashMap();
this.logs = new ArrayList();
@@ -82,6 +102,18 @@ public class Span {
this(spanId, -1, operationName);
}
+ /**
+ * Create a new span, by given span id and give startTime but no parent span id,
+ * No parent span id means that, this Span is the first span of the {@link TraceSegment}
+ *
+ * @param spanId given by the creator, and must be unique id in the {@link TraceSegment}
+ * @param operationName {@link #operationName}
+ * @param startTime given start time of span
+ */
+ public Span(int spanId, String operationName, long startTime) {
+ this(spanId, -1, operationName, startTime);
+ }
+
/**
* Create a new span, by given span id and given parent {@link Span}.
*
@@ -90,7 +122,32 @@ public class Span {
* @param operationName {@link #operationName}
*/
public Span(int spanId, Span parentSpan, String operationName) {
- this(spanId, parentSpan.spanId, operationName);
+ this(spanId, parentSpan.spanId, operationName, System.currentTimeMillis());
+ }
+
+ /**
+ * Create a new span, by given span id, parent span, operationName and startTime.
+ * This span must belong a {@link TraceSegment}, also is a part of Distributed Trace.
+ *
+ * @param spanId given by the creator, and must be unique id in the {@link TraceSegment}
+ * @param parentSpan {@link Span}
+ * @param operationName {@link #operationName}
+ * @param startTime given start timestamp
+ */
+ public Span(int spanId, Span parentSpan, String operationName, long startTime) {
+ this(spanId, parentSpan.spanId, operationName, startTime);
+ }
+
+ /**
+ * Create a new span, by given {@link SpanMessage}, which you can get from another {@link Span} object,
+ * by calling {@link Span#serialize()};
+ *
+ * @param spanMessage from another {@link Span#serialize()}
+ */
+ public Span(SpanMessage spanMessage) {
+ tags = new HashMap();
+ logs = new LinkedList();
+ this.deserialize(spanMessage);
}
/**
@@ -100,12 +157,36 @@ public class Span {
* @param owner of the Span.
*/
public void finish(TraceSegment owner) {
- this.endTime = System.currentTimeMillis();
+ this.finish(owner, System.currentTimeMillis());
+ }
+
+ /**
+ * Finish the active Span.
+ * When it is finished, it will be archived by the given {@link TraceSegment}, which owners it.
+ * At the same out, set the {@link #endTime} as the given endTime
+ *
+ * @param owner of the Span.
+ * @param endTime of the Span.
+ */
+ public void finish(TraceSegment owner, long endTime) {
+ this.endTime = endTime;
owner.archive(this);
}
+ /**
+ * Sets the string name for the logical operation this span represents.
+ *
+ * @return this Span instance, for chaining
+ */
+ public Span setOperationName(String operationName) {
+ this.operationName = operationName;
+ return this;
+ }
+
/**
* Set a key:value tag on the Span.
+ *
+ * @return this Span instance, for chaining
*/
public final Span setTag(String key, String value) {
tags.put(key, value);
@@ -177,6 +258,7 @@ public class Span {
*/
public Span log(Throwable t) {
Map exceptionFields = new HashMap();
+ exceptionFields.put("event", "error");
exceptionFields.put("error.kind", t.getClass().getName());
exceptionFields.put("message", t.getMessage());
exceptionFields.put("stack", ThrowableTransformer.INSTANCE.convert2String(t, 4000));
@@ -184,6 +266,51 @@ public class Span {
return log(exceptionFields);
}
+ @Override
+ public SpanMessage serialize() {
+ SpanMessage.Builder builder = SpanMessage.newBuilder();
+ builder.setSpanId(spanId);
+ builder.setStartTime(startTime);
+ builder.setEndTime(endTime);
+ builder.setOperationName(operationName);
+ for (Map.Entry entry : tags.entrySet()) {
+ KeyValue.Builder tagEntryBuilder = KeyValue.newBuilder();
+ tagEntryBuilder.setKey(entry.getKey());
+ String value = String.valueOf(entry.getValue());
+ if (!StringUtil.isEmpty(value)) {
+ tagEntryBuilder.setValue(value);
+ }
+ builder.addTags(tagEntryBuilder);
+ }
+
+ for (LogData log : logs) {
+ builder.addLogs(log.serialize());
+ }
+ return builder.build();
+ }
+
+ @Override
+ public void deserialize(SpanMessage message) {
+ spanId = message.getSpanId();
+ startTime = message.getStartTime();
+ endTime = message.getEndTime();
+ operationName = message.getOperationName();
+
+ List tagsList = message.getTagsList();
+ if(tagsList != null){
+ for (KeyValue tag : tagsList) {
+ tags.put(tag.getKey(), tag.getValue());
+ }
+ }
+
+ List logsList = message.getLogsList();
+ if (logsList != null) {
+ for (LogDataMessage logDataMessage : logsList) {
+ logs.add(new LogData(logDataMessage));
+ }
+ }
+ }
+
private enum ThrowableTransformer {
INSTANCE;
diff --git a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegment.java b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegment.java
index 2aad0b3c8c..fde9e445f5 100644
--- a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegment.java
+++ b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegment.java
@@ -1,5 +1,9 @@
package com.a.eye.skywalking.trace;
+import com.a.eye.skywalking.messages.ISerializable;
+import com.a.eye.skywalking.trace.messages.proto.SegmentMessage;
+import com.a.eye.skywalking.trace.messages.proto.SegmentRefMessage;
+import com.a.eye.skywalking.trace.messages.proto.SpanMessage;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -13,7 +17,7 @@ import java.util.List;
*
* Created by wusheng on 2017/2/17.
*/
-public class TraceSegment {
+public class TraceSegment implements ISerializable {
/**
* The id of this trace segment.
* Every segment has its unique-global-id.
@@ -51,18 +55,36 @@ public class TraceSegment {
*/
private List spans;
+ /**
+ * The applicationCode represents a name of current application/JVM and indicates which is business
+ * role in the cluster.
+ *
+ * e.g. account_app, billing_app
+ */
+ private String applicationCode;
+
/**
* Create a trace segment, by given segmentId.
* This segmentId is generated by TraceSegmentRef, AKA, from tracer/agent module.
*
* @param segmentId {@link #traceSegmentId}
*/
- public TraceSegment(String segmentId) {
+ public TraceSegment(String segmentId, String applicationCode) {
this.traceSegmentId = segmentId;
+ this.applicationCode = applicationCode;
this.startTime = System.currentTimeMillis();
this.spans = new LinkedList();
}
+ /**
+ * Create a trace segment, by given {@link SegmentMessage}
+ *
+ * @param message from another {@link TraceSegment#serialize()}
+ */
+ public TraceSegment(SegmentMessage message) {
+ deserialize(message);
+ }
+
/**
* Establish the link between this segment and its parents.
* The first time, you {@link #ref(TraceSegmentRef)} to parent, it is affirmed as {@link #primaryRef}.
@@ -70,10 +92,10 @@ public class TraceSegment {
*
* @param refSegment {@link TraceSegmentRef}
*/
- public void ref(TraceSegmentRef refSegment){
- if(primaryRef == null){
+ public void ref(TraceSegmentRef refSegment) {
+ if (primaryRef == null) {
primaryRef = refSegment;
- }else {
+ } else {
if (refs == null) {
refs = new LinkedList();
}
@@ -87,7 +109,7 @@ public class TraceSegment {
*
* @param finishedSpan
*/
- public void archive(Span finishedSpan){
+ public void archive(Span finishedSpan) {
spans.add(finishedSpan);
}
@@ -96,9 +118,9 @@ public class TraceSegment {
*
* return this, for chaining
*/
- public TraceSegment finish(){
- this.endTime = System.currentTimeMillis();
- return this;
+ public TraceSegment finish() {
+ this.endTime = System.currentTimeMillis();
+ return this;
}
public String getTraceSegmentId() {
@@ -125,6 +147,10 @@ public class TraceSegment {
return Collections.unmodifiableList(spans);
}
+ public String getApplicationCode() {
+ return applicationCode;
+ }
+
@Override
public String toString() {
return "TraceSegment{" +
@@ -134,4 +160,47 @@ public class TraceSegment {
", spans.size=" + spans.size() +
'}';
}
+
+ @Override
+ public SegmentMessage serialize() {
+ SegmentMessage.Builder segmentBuilder = SegmentMessage.newBuilder();
+ segmentBuilder.setTraceSegmentId(traceSegmentId);
+ segmentBuilder.setStartTime(startTime);
+ segmentBuilder.setEndTime(endTime);
+ segmentBuilder.setApplicationCode(applicationCode);
+ segmentBuilder.setPrimaryRef(primaryRef.serialize());
+ for (TraceSegmentRef ref : refs) {
+ segmentBuilder.addRefs(ref.serialize());
+ }
+ for (Span span : spans) {
+ segmentBuilder.addSpans(span.serialize());
+ }
+ return segmentBuilder.build();
+ }
+
+ @Override
+ public void deserialize(SegmentMessage message) {
+ traceSegmentId = message.getTraceSegmentId();
+ startTime = message.getStartTime();
+ endTime = message.getEndTime();
+ applicationCode = message.getApplicationCode();
+ (primaryRef = new TraceSegmentRef()).deserialize(message.getPrimaryRef());
+ List refsList = message.getRefsList();
+ if (refsList != null) {
+ this.refs = new LinkedList();
+ for (SegmentRefMessage refMessage : refsList) {
+ TraceSegmentRef ref = new TraceSegmentRef();
+ ref.deserialize(refMessage);
+ refs.add(ref);
+ }
+ }
+
+ List spansList = message.getSpansList();
+ if (spansList != null) {
+ this.spans = new LinkedList();
+ for (SpanMessage spanMessage : spansList) {
+ spans.add(new Span(spanMessage));
+ }
+ }
+ }
}
diff --git a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegmentRef.java b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegmentRef.java
index 8cea0a897b..098b54787d 100644
--- a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegmentRef.java
+++ b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegmentRef.java
@@ -1,12 +1,16 @@
package com.a.eye.skywalking.trace;
+import com.a.eye.skywalking.messages.ISerializable;
+import com.a.eye.skywalking.trace.messages.proto.SegmentRefMessage;
+import com.a.eye.skywalking.trace.tag.Tags;
+
/**
* {@link TraceSegmentRef} is like a pointer, which ref to another {@link TraceSegment},
* use {@link #spanId} point to the exact span of the ref {@link TraceSegment}.
*
* Created by wusheng on 2017/2/17.
*/
-public class TraceSegmentRef {
+public class TraceSegmentRef implements ISerializable {
/**
* {@link TraceSegment#traceSegmentId}
*/
@@ -17,6 +21,16 @@ public class TraceSegmentRef {
*/
private int spanId = -1;
+ /**
+ * {@link TraceSegment#applicationCode}
+ */
+ private String applicationCode;
+
+ /**
+ * {@link Tags#PEER_HOST}
+ */
+ private String peerHost;
+
/**
* Create a {@link TraceSegmentRef} instance, without any data.
*/
@@ -39,11 +53,48 @@ public class TraceSegmentRef {
this.spanId = spanId;
}
- @Override
- public String toString() {
+ public String getApplicationCode() {
+ return applicationCode;
+ }
+
+ public void setApplicationCode(String applicationCode) {
+ this.applicationCode = applicationCode;
+ }
+
+ public String getPeerHost() {
+ return peerHost;
+ }
+
+ public void setPeerHost(String peerHost) {
+ this.peerHost = peerHost;
+ }
+
+ @Override public String toString() {
return "TraceSegmentRef{" +
"traceSegmentId='" + traceSegmentId + '\'' +
", spanId=" + spanId +
+ ", applicationCode='" + applicationCode + '\'' +
+ ", peerHost='" + peerHost + '\'' +
'}';
}
+
+ @Override
+ public SegmentRefMessage serialize() {
+ SegmentRefMessage.Builder builder = SegmentRefMessage.newBuilder();
+ builder.setTraceSegmentId(traceSegmentId);
+ builder.setSpanId(spanId);
+ builder.setApplicationCode(applicationCode);
+ if(peerHost != null) {
+ builder.setPeerHost(peerHost);
+ }
+ return builder.build();
+ }
+
+ @Override
+ public void deserialize(SegmentRefMessage message) {
+ traceSegmentId = message.getTraceSegmentId();
+ spanId = message.getSpanId();
+ applicationCode = message.getApplicationCode();
+ peerHost = message.getPeerHost();
+ }
}
diff --git a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/BooleanTag.java b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/BooleanTag.java
index 6a6cd106b6..25de949d91 100644
--- a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/BooleanTag.java
+++ b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/BooleanTag.java
@@ -17,7 +17,20 @@ public class BooleanTag extends AbstractTag{
span.setTag(key, tagValue);
}
- @Override public Boolean get(Span span) {
- return (Boolean)span.getTag(super.key);
+ /**
+ * Get a tag value, type of {@link Boolean}.
+ * After akka-message/serialize, all tags values are type of {@link String}, convert to {@link Boolean}, if necessary.
+ *
+ * @param span
+ * @return tag value
+ */
+ @Override
+ public Boolean get(Span span) {
+ Object tagValue = span.getTag(super.key);
+ if(tagValue instanceof Boolean){
+ return (Boolean)tagValue;
+ }else {
+ return Boolean.valueOf(tagValue.toString());
+ }
}
}
diff --git a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/IntTag.java b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/IntTag.java
index 758374ada6..2157ff9936 100644
--- a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/IntTag.java
+++ b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/IntTag.java
@@ -17,7 +17,20 @@ public class IntTag extends AbstractTag {
span.setTag(super.key, tagValue);
}
- @Override public Integer get(Span span) {
- return (Integer)span.getTag(super.key);
+ /**
+ * Get a tag value, type of {@link Integer}.
+ * After akka-message/serialize, all tags values are type of {@link String}, convert to {@link Integer}, if necessary.
+ *
+ * @param span
+ * @return tag value
+ */
+ @Override
+ public Integer get(Span span) {
+ Object tagValue = span.getTag(super.key);
+ if(tagValue instanceof Integer){
+ return (Integer)tagValue;
+ }else {
+ return Integer.valueOf(tagValue.toString());
+ }
}
}
diff --git a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/ShortTag.java b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/ShortTag.java
index ce81ea060b..5d0116e038 100644
--- a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/ShortTag.java
+++ b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/ShortTag.java
@@ -17,7 +17,19 @@ public class ShortTag extends AbstractTag {
span.setTag(super.key, tagValue);
}
+ /**
+ * Get a tag value, type of {@link Short}.
+ * After akka-message/serialize, all tags values are type of {@link String}, convert to {@link Short}, if necessary.
+ *
+ * @param span
+ * @return tag value
+ */
@Override public Short get(Span span) {
- return (Short)span.getTag(super.key);
+ Object tagValue = span.getTag(super.key);
+ if(tagValue instanceof Short){
+ return (Short)tagValue;
+ }else {
+ return Short.valueOf(tagValue.toString());
+ }
}
}
diff --git a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/Tags.java b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/Tags.java
index e706e975d5..67e841e45c 100644
--- a/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/Tags.java
+++ b/skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/tag/Tags.java
@@ -102,7 +102,7 @@ public final class Tags {
public static final BooleanTag ERROR = new BooleanTag("error");
/**
- * PEER_HOST records host address of the peer, maybe IPV4, IPV6 or hostname.
+ * PEER_HOST records host address (ip:port, or ip1:port1,ip2:port2) of the peer, maybe IPV4, IPV6 or hostname.
*/
public static final StringTag PEER_HOST = new StringTag("peer.host");
diff --git a/skywalking-commons/skywalking-trace/src/main/proto/trace.proto b/skywalking-commons/skywalking-trace/src/main/proto/trace.proto
new file mode 100644
index 0000000000..df53a6c2b2
--- /dev/null
+++ b/skywalking-commons/skywalking-trace/src/main/proto/trace.proto
@@ -0,0 +1,40 @@
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "com.a.eye.skywalking.trace.messages.proto";
+
+message SegmentMessage {
+ string traceSegmentId = 1;
+ int64 startTime = 2;
+ int64 endTime = 3;
+ string applicationCode = 4;
+ SegmentRefMessage primaryRef = 5;
+ repeated SegmentRefMessage refs = 6;
+ repeated SpanMessage spans = 7;
+}
+
+message SegmentRefMessage {
+ string traceSegmentId = 1;
+ int32 spanId = 2;
+ string applicationCode = 3;
+ string peerHost = 4;
+}
+
+message SpanMessage {
+ int32 spanId = 1;
+ int64 startTime = 2;
+ int64 endTime = 3;
+ string operationName = 4;
+ repeated KeyValue tags = 5;
+ repeated LogDataMessage logs = 6;
+}
+
+message LogDataMessage {
+ int64 time = 1;
+ repeated KeyValue fields = 5;
+}
+
+message KeyValue {
+ string key = 1;
+ string value = 2;
+}
diff --git a/skywalking-commons/skywalking-trace/src/test/java/com/a/eye/skywalking/trace/SpanTestCase.java b/skywalking-commons/skywalking-trace/src/test/java/com/a/eye/skywalking/trace/SpanTestCase.java
index 8108a2aad7..f1b05855b1 100644
--- a/skywalking-commons/skywalking-trace/src/test/java/com/a/eye/skywalking/trace/SpanTestCase.java
+++ b/skywalking-commons/skywalking-trace/src/test/java/com/a/eye/skywalking/trace/SpanTestCase.java
@@ -14,6 +14,8 @@ public class SpanTestCase {
public void testConstructors() {
Span span1 = new Span(0, "serviceA");
Span span2 = new Span(2, span1, "serviceA");
+ span2.setOperationName("serviceA-2");
+ Assert.assertEquals("serviceA-2", span2.getOperationName());
Assert.assertEquals(-1, span1.getParentSpanId());
Assert.assertEquals(0, span2.getParentSpanId());
@@ -23,7 +25,7 @@ public class SpanTestCase {
@Test
public void testFinish() {
- TraceSegment owner = new TraceSegment("trace_1");
+ TraceSegment owner = new TraceSegment("trace_1", "billing_app");
Span span1 = new Span(0, "serviceA");
diff --git a/skywalking-commons/skywalking-trace/src/test/java/com/a/eye/skywalking/trace/TraceSegmentTestCase.java b/skywalking-commons/skywalking-trace/src/test/java/com/a/eye/skywalking/trace/TraceSegmentTestCase.java
index 401c9f3805..46843831f8 100644
--- a/skywalking-commons/skywalking-trace/src/test/java/com/a/eye/skywalking/trace/TraceSegmentTestCase.java
+++ b/skywalking-commons/skywalking-trace/src/test/java/com/a/eye/skywalking/trace/TraceSegmentTestCase.java
@@ -1,5 +1,6 @@
package com.a.eye.skywalking.trace;
+import com.a.eye.skywalking.trace.tag.Tags;
import org.junit.Assert;
import org.junit.Test;
@@ -8,16 +9,17 @@ import org.junit.Test;
*/
public class TraceSegmentTestCase {
@Test
- public void testConstructor(){
- TraceSegment segment = new TraceSegment("trace_1");
+ public void testConstructor() {
+ TraceSegment segment = new TraceSegment("trace_1", "billing_app");
Assert.assertEquals("trace_1", segment.getTraceSegmentId());
Assert.assertTrue(segment.getStartTime() > 0);
+ Assert.assertEquals("billing_app", segment.getApplicationCode());
}
@Test
- public void testRef(){
- TraceSegment segment = new TraceSegment("trace_3");
+ public void testRef() {
+ TraceSegment segment = new TraceSegment("trace_3", "billing_app");
TraceSegmentRef ref1 = new TraceSegmentRef();
ref1.setTraceSegmentId("parent_trace_0");
@@ -43,8 +45,8 @@ public class TraceSegmentTestCase {
}
@Test
- public void testArchiveSpan(){
- TraceSegment segment = new TraceSegment("trace_1");
+ public void testArchiveSpan() {
+ TraceSegment segment = new TraceSegment("trace_1", "billing_app");
Span span1 = new Span(1, "/serviceA");
segment.archive(span1);
@@ -56,11 +58,53 @@ public class TraceSegmentTestCase {
}
@Test
- public void testFinish(){
- TraceSegment segment = new TraceSegment("trace_1");
+ public void testFinish() {
+ TraceSegment segment = new TraceSegment("trace_1", "billing_app");
Assert.assertTrue(segment.getEndTime() == 0);
segment.finish();
Assert.assertTrue(segment.getEndTime() > 0);
}
+
+ @Test
+ public void testSerialize() {
+ TraceSegment segment = new TraceSegment("trace_3", "billing_app");
+
+ TraceSegmentRef ref1 = new TraceSegmentRef();
+ ref1.setTraceSegmentId("parent_trace_0");
+ ref1.setSpanId(1);
+ ref1.setApplicationCode("REMOTE_APP");
+ ref1.setPeerHost("10.2.3.16:8080");
+ segment.ref(ref1);
+
+ TraceSegmentRef ref2 = new TraceSegmentRef();
+ ref2.setTraceSegmentId("parent_trace_1");
+ ref2.setSpanId(5);
+ ref2.setApplicationCode("REMOTE_APP");
+ ref2.setPeerHost("10.2.3.16:8080");
+ segment.ref(ref2);
+
+ TraceSegmentRef ref3 = new TraceSegmentRef();
+ ref3.setTraceSegmentId("parent_trace_1");
+ ref3.setSpanId(5);
+ ref3.setApplicationCode("REMOTE_APP");
+ ref3.setPeerHost("10.2.3.16:8080");
+ segment.ref(ref3);
+
+ Span span1 = new Span(1, "/serviceA");
+ Tags.SPAN_LAYER.asHttp(span1);
+ segment.archive(span1);
+
+ Span span2 = new Span(2, span1, "/db/sql");
+ Tags.SPAN_LAYER.asNoSQL(span2);
+ span2.log(new NullPointerException());
+ segment.archive(span2);
+
+ TraceSegment newSegment = new TraceSegment(segment.serialize());
+
+ Assert.assertEquals(segment.getSpans().size(), newSegment.getSpans().size());
+ Assert.assertEquals(segment.getPrimaryRef().getTraceSegmentId(), newSegment.getPrimaryRef().getTraceSegmentId());
+ Assert.assertEquals(Tags.SPAN_LAYER.get(segment.getSpans().get(0)), Tags.SPAN_LAYER.get(newSegment.getSpans().get(0)));
+ Assert.assertEquals(segment.getSpans().get(1).getLogs().get(0).getTime(), newSegment.getSpans().get(1).getLogs().get(0).getTime());
+ }
}
diff --git a/skywalking-sniffer/skywalking-api/pom.xml b/skywalking-sniffer/skywalking-api/pom.xml
index 5774f18bda..5d898ca265 100644
--- a/skywalking-sniffer/skywalking-api/pom.xml
+++ b/skywalking-sniffer/skywalking-api/pom.xml
@@ -46,11 +46,6 @@
skywalking-logging-api
${project.version}
-
- com.lmax
- disruptor
- 3.3.6
-
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextCarrier.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextCarrier.java
index 30d880d09c..a7d5a96ed0 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextCarrier.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextCarrier.java
@@ -1,7 +1,9 @@
package com.a.eye.skywalking.api.context;
-import com.a.eye.skywalking.trace.TraceSegmentRef;
+import com.a.eye.skywalking.trace.Span;
+import com.a.eye.skywalking.trace.TraceSegment;
import com.a.eye.skywalking.api.util.StringUtil;
+import com.a.eye.skywalking.trace.tag.Tags;
import java.io.Serializable;
/**
@@ -10,7 +12,26 @@ import java.io.Serializable;
*
* Created by wusheng on 2017/2/17.
*/
-public class ContextCarrier extends TraceSegmentRef implements Serializable {
+public class ContextCarrier implements Serializable {
+ /**
+ * {@link TraceSegment#traceSegmentId}
+ */
+ private String traceSegmentId;
+
+ /**
+ * {@link Span#spanId}
+ */
+ private int spanId = -1;
+
+ /**
+ * {@link TraceSegment#applicationCode}
+ */
+ private String applicationCode;
+
+ /**
+ * {@link Tags#PEER_HOST}
+ */
+ private String peerHost;
/**
* Serialize this {@link ContextCarrier} to a {@link String},
@@ -19,7 +40,7 @@ public class ContextCarrier extends TraceSegmentRef implements Serializable {
* @return the serialization string.
*/
public String serialize() {
- return StringUtil.join('|', this.getTraceSegmentId(), this.getSpanId() + "");
+ return StringUtil.join('|', this.getTraceSegmentId(), this.getSpanId() + "", this.getApplicationCode(), this.getPeerHost());
}
/**
@@ -29,11 +50,13 @@ public class ContextCarrier extends TraceSegmentRef implements Serializable {
*/
public ContextCarrier deserialize(String text) {
if(text != null){
- String[] parts = text.split("\\|");
- if(parts.length == 2){
+ String[] parts = text.split("\\|", 4);
+ if(parts.length == 4){
try{
setSpanId(Integer.parseInt(parts[1]));
setTraceSegmentId(parts[0]);
+ setApplicationCode(parts[2]);
+ setPeerHost(parts[3]);
}catch(NumberFormatException e){
}
@@ -48,7 +71,38 @@ public class ContextCarrier extends TraceSegmentRef implements Serializable {
* @return true for unbroken {@link ContextCarrier} or no-initialized. Otherwise, false;
*/
public boolean isValid(){
- return !StringUtil.isEmpty(getTraceSegmentId()) && getSpanId() > -1;
+ return !StringUtil.isEmpty(traceSegmentId) && getSpanId() > -1 && !StringUtil.isEmpty(applicationCode) && !StringUtil.isEmpty(peerHost);
}
+ public String getTraceSegmentId() {
+ return traceSegmentId;
+ }
+
+ public int getSpanId() {
+ return spanId;
+ }
+
+ public void setTraceSegmentId(String traceSegmentId) {
+ this.traceSegmentId = traceSegmentId;
+ }
+
+ public void setSpanId(int spanId) {
+ this.spanId = spanId;
+ }
+
+ public String getApplicationCode() {
+ return applicationCode;
+ }
+
+ public void setApplicationCode(String applicationCode) {
+ this.applicationCode = applicationCode;
+ }
+
+ public String getPeerHost() {
+ return peerHost;
+ }
+
+ public void setPeerHost(String peerHost) {
+ this.peerHost = peerHost;
+ }
}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextManager.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextManager.java
index 2ff3305093..9fe501c2af 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextManager.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/ContextManager.java
@@ -57,6 +57,10 @@ public enum ContextManager implements TracerContextListener {
return get().createSpan(operationName);
}
+ public Span createSpan(String operationName, long startTime) {
+ return get().createSpan(operationName);
+ }
+
public Span activeSpan() {
return get().activeSpan();
}
@@ -65,6 +69,10 @@ public enum ContextManager implements TracerContextListener {
get().stopSpan(span);
}
+ public void stopSpan(Long endTime) {
+ get().stopSpan(activeSpan(), endTime);
+ }
+
public void stopSpan() {
stopSpan(activeSpan());
}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/TracerContext.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/TracerContext.java
index 4ef3d31884..31e6fe6de0 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/TracerContext.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/TracerContext.java
@@ -1,8 +1,11 @@
package com.a.eye.skywalking.api.context;
+import com.a.eye.skywalking.api.conf.Config;
import com.a.eye.skywalking.trace.Span;
import com.a.eye.skywalking.trace.TraceSegment;
import com.a.eye.skywalking.api.util.TraceIdGenerator;
+import com.a.eye.skywalking.trace.TraceSegmentRef;
+import com.a.eye.skywalking.trace.tag.Tags;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -28,8 +31,11 @@ public final class TracerContext {
private int spanIdGenerator;
+ /**
+ * Create a {@link TraceSegment} and init {@link #spanIdGenerator} as 0;
+ */
TracerContext() {
- this.segment = new TraceSegment(TraceIdGenerator.generate());
+ this.segment = new TraceSegment(TraceIdGenerator.generate(), Config.SkyWalking.APPLICATION_CODE);
this.spanIdGenerator = 0;
}
@@ -40,12 +46,23 @@ public final class TracerContext {
* @return the new active span.
*/
public Span createSpan(String operationName) {
+ return this.createSpan(operationName, System.currentTimeMillis());
+ }
+
+ /**
+ * Create a new span, as an active span, by the given operationName and startTime;
+ *
+ * @param operationName {@link Span#operationName}
+ * @param startTime {@link Span#startTime}
+ * @return
+ */
+ public Span createSpan(String operationName, long startTime){
Span parentSpan = peek();
Span span;
if (parentSpan == null) {
- span = new Span(spanIdGenerator++, operationName);
+ span = new Span(spanIdGenerator++, operationName, startTime);
} else {
- span = new Span(spanIdGenerator++, parentSpan, operationName);
+ span = new Span(spanIdGenerator++, parentSpan, operationName, startTime);
}
push(span);
return span;
@@ -68,9 +85,13 @@ public final class TracerContext {
* @param span to finish. It must the the top element of {@link #activeSpanStack}.
*/
public void stopSpan(Span span) {
+ stopSpan(span, System.currentTimeMillis());
+ }
+
+ public void stopSpan(Span span, Long endTime){
Span lastSpan = peek();
if (lastSpan == span) {
- segment.archive(pop());
+ pop().finish(segment, endTime);
} else {
throw new IllegalStateException("Stopping the unexpected span = " + span);
}
@@ -96,6 +117,8 @@ public final class TracerContext {
public void inject(ContextCarrier carrier) {
carrier.setTraceSegmentId(this.segment.getTraceSegmentId());
carrier.setSpanId(this.activeSpan().getSpanId());
+ carrier.setApplicationCode(Config.SkyWalking.APPLICATION_CODE);
+ carrier.setPeerHost(Tags.PEER_HOST.get(activeSpan()));
}
/**
@@ -105,7 +128,12 @@ public final class TracerContext {
* ContextCarrier#deserialize(String)} called.
*/
public void extract(ContextCarrier carrier) {
- this.segment.ref(carrier);
+ TraceSegmentRef ref = new TraceSegmentRef();
+ ref.setTraceSegmentId(carrier.getTraceSegmentId());
+ ref.setSpanId(carrier.getSpanId());
+ ref.setApplicationCode(carrier.getApplicationCode());
+ ref.setPeerHost(carrier.getPeerHost());
+ this.segment.ref(ref);
}
/**
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/util/RoutingKeyGenerator.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/util/RoutingKeyGenerator.java
deleted file mode 100644
index a335eaab8d..0000000000
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/util/RoutingKeyGenerator.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.a.eye.skywalking.api.util;
-
-/**
- * Created data xin on 2016/12/4.
- */
-public class RoutingKeyGenerator {
-
- public static int generate(String originData) {
- char[] value = originData.toCharArray();
- int h = 0;
- if (h == 0 && value.length > 0) {
- char val[] = value;
-
- for (int i = 0; i < value.length; i++) {
- h = 31 * h + val[i];
- }
- }
- return h;
- }
-}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/ContextCarrierTestCase.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/ContextCarrierTestCase.java
index 805090e07c..8b6e1fc263 100644
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/ContextCarrierTestCase.java
+++ b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/ContextCarrierTestCase.java
@@ -12,17 +12,21 @@ public class ContextCarrierTestCase {
ContextCarrier carrier = new ContextCarrier();
carrier.setTraceSegmentId("trace_id_A");
carrier.setSpanId(100);
+ carrier.setApplicationCode("REMOTE_APP");
+ carrier.setPeerHost("10.2.3.16:8080");
- Assert.assertEquals("trace_id_A|100", carrier.serialize());
+ Assert.assertEquals("trace_id_A|100|REMOTE_APP|10.2.3.16:8080", carrier.serialize());
}
@Test
public void testDeserialize(){
ContextCarrier carrier = new ContextCarrier();
- carrier.deserialize("trace_id_A|100");
+ carrier.deserialize("trace_id_A|100|REMOTE_APP|10.2.3.16:8080");
Assert.assertEquals("trace_id_A", carrier.getTraceSegmentId());
Assert.assertEquals(100, carrier.getSpanId());
+ Assert.assertEquals("REMOTE_APP", carrier.getApplicationCode());
+ Assert.assertEquals("10.2.3.16:8080", carrier.getPeerHost());
}
@Test
@@ -44,7 +48,7 @@ public class ContextCarrierTestCase {
Assert.assertFalse(carrier.isValid());
carrier = new ContextCarrier();
- carrier.deserialize("trace_id|100");
+ carrier.deserialize("trace_id|100|REMOTE_APP|10.2.3.16:8080");
Assert.assertTrue(carrier.isValid());
}
}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/TracerContextTestCase.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/TracerContextTestCase.java
index 15389ff9bd..cd8478f511 100644
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/TracerContextTestCase.java
+++ b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/context/TracerContextTestCase.java
@@ -2,6 +2,7 @@ package com.a.eye.skywalking.api.context;
import com.a.eye.skywalking.trace.Span;
import com.a.eye.skywalking.trace.TraceSegment;
+import com.a.eye.skywalking.trace.tag.Tags;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
@@ -56,11 +57,12 @@ public class TracerContextTestCase {
TracerContext context = new TracerContext();
Span serviceSpan = context.createSpan("/serviceA");
Span dbSpan = context.createSpan("db/preparedStatement/execute");
+ Tags.PEER_HOST.set(dbSpan, "127.0.0.1:8080");
ContextCarrier carrier = new ContextCarrier();
context.inject(carrier);
- Assert.assertTrue(carrier.isValid());
+ Assert.assertEquals("127.0.0.1:8080", carrier.getPeerHost());
Assert.assertEquals(1, carrier.getSpanId());
}
@@ -69,6 +71,8 @@ public class TracerContextTestCase {
ContextCarrier carrier = new ContextCarrier();
carrier.setTraceSegmentId("trace_id_1");
carrier.setSpanId(5);
+ carrier.setApplicationCode("REMOTE_APP");
+ carrier.setPeerHost("10.2.3.16:8080");
Assert.assertTrue(carrier.isValid());
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/BeInterceptedClass.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/BeInterceptedClass.java
deleted file mode 100644
index 2f501a8d4a..0000000000
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/BeInterceptedClass.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.a.eye.skywalking.api.plugin;
-
-public class BeInterceptedClass {
- public BeInterceptedClass(){
- System.out.println("BeInterceptedClass constructor.");
- }
-
- public void printabc(){
- System.out.println("printabc");
- }
-
- public static void call(){
- System.out.println("static call");
- }
-}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/PluginMainTest.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/PluginMainTest.java
deleted file mode 100644
index df0fe92f64..0000000000
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/PluginMainTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.a.eye.skywalking.api.plugin;
-
-import org.junit.Test;
-
-import java.lang.reflect.InvocationTargetException;
-
-public class PluginMainTest {
- @Test
- public void testMain() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, PluginException {
- TracingBootstrap.main(new String[] {"PluginMainTest"});
- }
-
- public static void main(String[] args)
- throws InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
- SecurityException {
- long start = System.currentTimeMillis();
-
- BeInterceptedClass inst = (BeInterceptedClass) Class.forName("BeInterceptedClass").newInstance();
- inst.printabc();
- long end = System.currentTimeMillis();
- System.out.println(end - start + "ms");
-
- BeInterceptedClass.call();
- }
-}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/PluginResourceResoverTest.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/PluginResourceResoverTest.java
deleted file mode 100644
index d7b1f98281..0000000000
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/PluginResourceResoverTest.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.a.eye.skywalking.api.plugin;
-
-import java.io.IOException;
-
-public class PluginResourceResoverTest {
-
- public static void main(String[] args) throws IOException {
- PluginResourcesResolver resolver = new PluginResourcesResolver();
- resolver.getResources();
- }
-
-}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/TestAroundInterceptor.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/TestAroundInterceptor.java
deleted file mode 100644
index 2c37506c28..0000000000
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/TestAroundInterceptor.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.a.eye.skywalking.api.plugin;
-
-import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
-
-public class TestAroundInterceptor implements InstanceMethodsAroundInterceptor {
-
- @Override
- public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
- System.out.println("beforeMethod : " + context.get("test.key", String.class));
- }
-
- @Override
- public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
- System.out.println("afterMethod: " + context.get("test.key", String.class));
- return ret;
- }
-
- @Override
- public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/TestInterceptorDefine.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/TestInterceptorDefine.java
deleted file mode 100644
index cc5024b6d0..0000000000
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/TestInterceptorDefine.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.a.eye.skywalking.api.plugin;
-
-import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
-import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
-import com.a.eye.skywalking.api.plugin.interceptor.StaticMethodsInterceptPoint;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassEnhancePluginDefine;
-import net.bytebuddy.description.method.MethodDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-
-import static net.bytebuddy.matcher.ElementMatchers.named;
-
-public class TestInterceptorDefine extends ClassEnhancePluginDefine {
-
- @Override
- public String enhanceClassName() {
- return "BeInterceptedClass";
- }
-
- @Override
- protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return null;
- }
-
- @Override
- protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
- return new InstanceMethodsInterceptPoint[] {new InstanceMethodsInterceptPoint() {
- @Override
- public ElementMatcher getMethodsMatcher() {
- return named("printabc");
- }
-
- @Override
- public String getMethodsInterceptor() {
- return "TestAroundInterceptor";
- }
- }};
- }
-
- @Override
- protected StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints() {
- return new StaticMethodsInterceptPoint[] {new StaticMethodsInterceptPoint() {
- @Override
- public ElementMatcher getMethodsMatcher() {
- return named("call");
- }
-
- @Override
- public String getMethodsInterceptor() {
- return "TestStaticAroundInterceptor";
- }
- }};
- }
-}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/TestStaticAroundInterceptor.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/TestStaticAroundInterceptor.java
deleted file mode 100644
index 07dd955acc..0000000000
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/api/plugin/TestStaticAroundInterceptor.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.a.eye.skywalking.api.plugin;
-
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInvokeContext;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.StaticMethodInvokeContext;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
-
-public class TestStaticAroundInterceptor implements StaticMethodsAroundInterceptor {
-
- @Override
- public void beforeMethod(StaticMethodInvokeContext interceptorContext, MethodInterceptResult result) {
- System.out.println("beforeMethod : static");
- }
-
- @Override
- public Object afterMethod(StaticMethodInvokeContext interceptorContext, Object ret) {
- System.out.println("afterMethod: static");
- return ret;
- }
-
- @Override
- public void handleMethodException(Throwable t, MethodInvokeContext interceptorContext) {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/ConstructorInterceptor.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/ConstructorInterceptor.java
deleted file mode 100644
index dc9ebd9355..0000000000
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/ConstructorInterceptor.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.a.eye.skywalking.bytebuddy;
-
-import net.bytebuddy.implementation.bind.annotation.AllArguments;
-import net.bytebuddy.implementation.bind.annotation.RuntimeType;
-import net.bytebuddy.implementation.bind.annotation.This;
-
-public class ConstructorInterceptor {
- @RuntimeType
- public void intercept(@AllArguments Object[] allArguments) {
- System.out
- .println("ConstructorInterceptor size:" + allArguments.length);
- if(allArguments.length > 0){
- System.out.println("ConstructorInterceptor param[0]=" + allArguments[0]);
- }
- }
-}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/MethodInterceptor.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/MethodInterceptor.java
deleted file mode 100644
index b46b348f98..0000000000
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/MethodInterceptor.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.a.eye.skywalking.bytebuddy;
-
-import java.lang.reflect.Method;
-import java.util.concurrent.Callable;
-
-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 net.bytebuddy.implementation.bind.annotation.This;
-
-public class MethodInterceptor{
- @RuntimeType
- public Object intercept(@This Object obj, @AllArguments Object[] allArguments, @Origin Method method, @SuperCall Callable> zuper){
- try {
- return method.getName() + ":intercept_" + zuper.call();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- }
- }
-}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/SimulateMain.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/SimulateMain.java
deleted file mode 100644
index bf47fa560d..0000000000
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/SimulateMain.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.a.eye.skywalking.bytebuddy;
-
-import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
-import static net.bytebuddy.matcher.ElementMatchers.isMethod;
-import net.bytebuddy.ByteBuddy;
-import net.bytebuddy.dynamic.ClassFileLocator;
-import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
-import net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy;
-import net.bytebuddy.implementation.MethodDelegation;
-import net.bytebuddy.implementation.SuperMethodCall;
-import net.bytebuddy.pool.TypePool;
-
-public class SimulateMain {
- public static void main(String[] args) throws NoSuchFieldException,
- SecurityException, InstantiationException, IllegalAccessException, ClassNotFoundException {
- TypePool typePool = TypePool.Default.ofClassPath();
- System.out.println(typePool.describe("TestClass").isResolved());
-
- Class> newClazz = new ByteBuddy()
- .redefine(
- typePool.describe("TestClass")
- .resolve(),
- ClassFileLocator.ForClassLoader.ofClassPath())
- .name("TestClass$$Origin")
- .make()
- .load(ClassLoader.getSystemClassLoader(),
- ClassLoadingStrategy.Default.INJECTION).getLoaded();
-
- TestClass t22 = (TestClass) (new ByteBuddy()
- .subclass(newClazz, ConstructorStrategy.Default.IMITATE_SUPER_CLASS)
- .method(isMethod())
- .intercept(MethodDelegation.to(new MethodInterceptor()))
- .constructor(isConstructor())
- .intercept(MethodDelegation.to(new ConstructorInterceptor()).andThen(SuperMethodCall.INSTANCE))
- .name("TestClass")
- .make()
- .load(ClassLoader.getSystemClassLoader(),
- ClassLoadingStrategy.Default.INJECTION).getLoaded()
- .newInstance());
-
- // System.out.println(t22.testA("1"));
- TestClass t = new TestClass("abc");
- System.out.println(t.testA("1"));
-
- t = new TestClass("abc");
- System.out.println(t.testA("1"));
-
-// TestClass t2 = null;
-// try {
-// t2 = (TestClass) Class.forName("TestClass")
-// .newInstance();
-// } catch (ClassNotFoundException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-// System.out.println(t2.testA("1"));
- }
-}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/SimulateMain2.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/SimulateMain2.java
deleted file mode 100644
index 793cc39691..0000000000
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/SimulateMain2.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.a.eye.skywalking.bytebuddy;
-
-import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
-import static net.bytebuddy.matcher.ElementMatchers.named;
-import net.bytebuddy.ByteBuddy;
-import net.bytebuddy.dynamic.ClassFileLocator;
-import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
-import net.bytebuddy.implementation.MethodDelegation;
-import net.bytebuddy.implementation.SuperMethodCall;
-import net.bytebuddy.pool.TypePool;
-
-public class SimulateMain2 {
- public static void main(String[] args) throws InstantiationException,
- IllegalAccessException {
- TypePool typePool = TypePool.Default.ofClassPath();
-
- new ByteBuddy()
- .rebase(typePool.describe("TestClass")
- .resolve(),
- ClassFileLocator.ForClassLoader.ofClassPath())
- .method(named("testA"))
- .intercept(MethodDelegation.to(new MethodInterceptor()))
- .method(named("testB"))
- .intercept(MethodDelegation.to(new MethodInterceptor()))
- .constructor(isConstructor())
- .intercept(
- MethodDelegation.to(new ConstructorInterceptor())
- .andThen(SuperMethodCall.INSTANCE))
- .make()
- .load(ClassLoader.getSystemClassLoader(),
- ClassLoadingStrategy.Default.INJECTION).getLoaded();
-
- TestClass t = new TestClass("abc");
- System.out.println(t.testA("1"));
- }
-}
diff --git a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/TestClass.java b/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/TestClass.java
deleted file mode 100644
index d30f1b60cd..0000000000
--- a/skywalking-sniffer/skywalking-api/src/test/java/com/a/eye/skywalking/bytebuddy/TestClass.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.a.eye.skywalking.bytebuddy;
-
-public class TestClass {
- public TestClass(){
- //System.out.println("init:" + this.getClass().getName());
- }
-
- public TestClass(String tmp){
- //System.out.println("init:" + this.getClass().getName());
- }
-
-
- public String testA(String aa){
-// throw new RuntimeException("adfasdfas");
- return "TestClass.testA";
- }
-}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/PrintTraceIdInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/PrintTraceIdInterceptor.java
index b70b9173da..9c90914452 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/PrintTraceIdInterceptor.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/PrintTraceIdInterceptor.java
@@ -1,8 +1,9 @@
package com.a.eye.skywalking.toolkit.activation.log.log4j.v1.x;
-import com.a.eye.skywalking.api.Tracing;
+import com.a.eye.skywalking.api.context.ContextCarrier;
+import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
@@ -25,7 +26,9 @@ public class PrintTraceIdInterceptor implements InstanceMethodsAroundInterceptor
*/
@Override
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
- return "TID:" + Tracing.getTraceId();
+ ContextCarrier carrier = new ContextCarrier();
+ ContextManager.INSTANCE.inject(carrier);
+ return "TID:" + carrier.getTraceSegmentId();
}
@Override
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/TraceIdPatternConverterActivation.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/TraceIdPatternConverterActivation.java
index 1f06344d3e..1bb3f0f8b3 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/TraceIdPatternConverterActivation.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v1/x/TraceIdPatternConverterActivation.java
@@ -1,9 +1,8 @@
package com.a.eye.skywalking.toolkit.activation.log.log4j.v1.x;
-import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
+import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
-import com.a.eye.skywalking.plugin.interceptor.StaticMethodsInterceptPoint;
-import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/Log4j2OutputAppenderActivation.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/Log4j2OutputAppenderActivation.java
index fd6f4ee7bc..be70f30ff8 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/Log4j2OutputAppenderActivation.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/Log4j2OutputAppenderActivation.java
@@ -1,7 +1,7 @@
package com.a.eye.skywalking.toolkit.activation.log.log4j.v2.x;
-import com.a.eye.skywalking.plugin.interceptor.StaticMethodsInterceptPoint;
-import com.a.eye.skywalking.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine;
+import com.a.eye.skywalking.api.plugin.interceptor.StaticMethodsInterceptPoint;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/PrintTraceIdInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/PrintTraceIdInterceptor.java
index 46840d3bf4..d8faef9e70 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/PrintTraceIdInterceptor.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-log4j-2.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/log4j/v2/x/PrintTraceIdInterceptor.java
@@ -1,6 +1,11 @@
package com.a.eye.skywalking.toolkit.activation.log.log4j.v2.x;
-import com.a.eye.skywalking.api.Tracing;
+import com.a.eye.skywalking.api.context.ContextCarrier;
+import com.a.eye.skywalking.api.context.ContextManager;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.StaticMethodInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
/**
* Created by wusheng on 2016/12/7.
@@ -14,7 +19,9 @@ public class PrintTraceIdInterceptor implements StaticMethodsAroundInterceptor {
*/
@Override
public void beforeMethod(StaticMethodInvokeContext interceptorContext, MethodInterceptResult result) {
- ((StringBuilder) interceptorContext.allArguments()[0]).append("TID:" + Tracing.getTraceId());
+ ContextCarrier carrier = new ContextCarrier();
+ ContextManager.INSTANCE.inject(carrier);
+ ((StringBuilder) interceptorContext.allArguments()[0]).append("TID:" + carrier.getTraceSegmentId());
//make sure origin method do not invoke.
result.defineReturnValue(null);
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/LogbackPatternConverterActivation.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/LogbackPatternConverterActivation.java
index 6379d9685d..02ff96d6d9 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/LogbackPatternConverterActivation.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/LogbackPatternConverterActivation.java
@@ -1,9 +1,9 @@
package com.a.eye.skywalking.toolkit.activation.log.logback.v1.x;
-import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
+import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
-import com.a.eye.skywalking.plugin.interceptor.StaticMethodsInterceptPoint;
-import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import com.a.eye.skywalking.api.plugin.interceptor.StaticMethodsInterceptPoint;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/PrintTraceIdInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/PrintTraceIdInterceptor.java
index 0677d4efa6..acc17953cb 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/PrintTraceIdInterceptor.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-logback-1.x-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/log/logback/v1/x/PrintTraceIdInterceptor.java
@@ -1,8 +1,9 @@
package com.a.eye.skywalking.toolkit.activation.log.logback.v1.x;
-import com.a.eye.skywalking.api.Tracing;
+import com.a.eye.skywalking.api.context.ContextCarrier;
+import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
@@ -25,7 +26,9 @@ public class PrintTraceIdInterceptor implements InstanceMethodsAroundInterceptor
*/
@Override
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
- return "TID:" + Tracing.getTraceId();
+ ContextCarrier carrier = new ContextCarrier();
+ ContextManager.INSTANCE.inject(carrier);
+ return "TID:" + carrier.getTraceSegmentId();
}
@Override
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/SkyWalkingSpanActivation.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/SkyWalkingSpanActivation.java
index 8fd58f621b..9f9884b2c9 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/SkyWalkingSpanActivation.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/SkyWalkingSpanActivation.java
@@ -1,16 +1,13 @@
package com.a.eye.skywalking.toolkit.activation.opentracing.span;
-import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
+import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
-import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
-
import java.util.Map;
-
import static net.bytebuddy.matcher.ElementMatchers.named;
-import static net.bytebuddy.matcher.ElementMatchers.noneOf;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
/**
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanFinishInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanFinishInterceptor.java
index 3af85ee90c..e008ffcf7a 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanFinishInterceptor.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanFinishInterceptor.java
@@ -1,36 +1,32 @@
package com.a.eye.skywalking.toolkit.activation.opentracing.span.interceptor;
-import com.a.eye.skywalking.api.Tracing;
-import com.a.eye.skywalking.invoke.monitor.LocalMethodInvokeMonitor;
-import com.a.eye.skywalking.model.Span;
+import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
-
-import java.util.Map;
+import com.a.eye.skywalking.toolkit.opentracing.SkyWalkingSpan;
/**
- * Created by xin on 2017/1/16.
+ * Intercept these following methods:
+ * {@link SkyWalkingSpan#finish()}
+ * {@link SkyWalkingSpan#finish(long)}
*/
public class SpanFinishInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
- // do nothing
}
@Override
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
- Span currentSpan = Tracing.getCurrentSpan();
+ Object[] allArguments = interceptorContext.allArguments();
- Map tags = (Map) context.get("tags");
- if (tags != null) {
- for (Map.Entry entry : tags.entrySet()) {
- Tracing.tag(currentSpan, entry.getKey(), entry.getValue());
- }
+ if(allArguments.length == 1) {
+ ContextManager.INSTANCE.stopSpan(((Long)allArguments[0]));
+ }else{
+ ContextManager.INSTANCE.stopSpan();
}
- new LocalMethodInvokeMonitor().afterInvoke();
return ret;
}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanNewInstanceInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanNewInstanceInterceptor.java
index d0821a41e6..73967ca7ae 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanNewInstanceInterceptor.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanNewInstanceInterceptor.java
@@ -1,18 +1,28 @@
package com.a.eye.skywalking.toolkit.activation.opentracing.span.interceptor;
+import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.ConstructorInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+import com.a.eye.skywalking.toolkit.opentracing.SkyWalkingSpan;
+import com.a.eye.skywalking.trace.Span;
+import java.util.Map;
/**
- * @author zhangxin
+ * Intercept {@link SkyWalkingSpan} constructor.
*/
public class SpanNewInstanceInterceptor implements InstanceConstructorInterceptor {
- private static final String OPERATION_NAME = "operationName";
-
@Override
public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
- context.set(OPERATION_NAME, interceptorContext.allArguments()[0]);
+ Object[] allArguments = interceptorContext.allArguments();
+ String operationName = ((String)allArguments[0]);
+ long startTime = ((Long)allArguments[1]);
+ Map tags = ((Map)allArguments[2]);
+ Span span = ContextManager.INSTANCE.createSpan(operationName, startTime);
+
+ for (Map.Entry entry : tags.entrySet()) {
+ span.setTag(entry.getKey(), entry.getValue());
+ }
}
}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetOperationNameInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetOperationNameInterceptor.java
index 5eb368ff0a..7f46ac3931 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetOperationNameInterceptor.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetOperationNameInterceptor.java
@@ -1,20 +1,21 @@
package com.a.eye.skywalking.toolkit.activation.opentracing.span.interceptor;
+import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
+import com.a.eye.skywalking.toolkit.opentracing.SkyWalkingSpan;
/**
- * Created by xin on 2017/1/16.
+ * Intercept {@link SkyWalkingSpan#setOperationName(String)}
*/
public class SpanSetOperationNameInterceptor implements InstanceMethodsAroundInterceptor {
- private static final String OPERATION_NAME = "operationName";
-
@Override
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
- context.set(OPERATION_NAME, interceptorContext.allArguments()[0]);
+ String operationName = (String)interceptorContext.allArguments()[0];
+ ContextManager.INSTANCE.activeSpan().setOperationName(operationName);
}
@Override
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java
index f8ee21cc7b..35d5ae3ec8 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/span/interceptor/SpanSetTagInterceptor.java
@@ -1,39 +1,42 @@
package com.a.eye.skywalking.toolkit.activation.opentracing.span.interceptor;
+import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
-
-import java.util.HashMap;
-import java.util.Map;
+import com.a.eye.skywalking.toolkit.opentracing.SkyWalkingSpan;
/**
- * Created by xin on 2017/1/16.
+ * Intercept these following methods:
+ * {@link SkyWalkingSpan#setTag(String, boolean)}
+ * {@link SkyWalkingSpan#setTag(String, Number)}
+ * {@link SkyWalkingSpan#setTag(String, String)}
*/
public class SpanSetTagInterceptor implements InstanceMethodsAroundInterceptor {
- private static final String TAGS = "tags";
-
@Override
- public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
- Map contextTags = (Map) context.get(TAGS);
- if (!context.isContain(TAGS)){
- contextTags = new HashMap();
- context.set(TAGS, contextTags);
- }
-
- contextTags.put((String) interceptorContext.allArguments()[0], String.valueOf(interceptorContext
- .allArguments()[1]));
+ public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext,
+ MethodInterceptResult result) {
+ String key = (String)interceptorContext.allArguments()[0];
+ Object value = interceptorContext.allArguments()[1];
+ if (value instanceof String)
+ ContextManager.INSTANCE.activeSpan().setTag(key, (String)value);
+ else if (value instanceof Boolean)
+ ContextManager.INSTANCE.activeSpan().setTag(key, (Boolean)value);
+ else if (value instanceof Number)
+ ContextManager.INSTANCE.activeSpan().setTag(key, (Number)value);
}
@Override
- public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
+ public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext,
+ Object ret) {
return ret;
}
@Override
- public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
+ public void handleMethodException(Throwable t, EnhancedClassInstanceContext context,
+ InstanceMethodInvokeContext interceptorContext) {
}
}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/OpenTracingLocalBuriedPointType.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/OpenTracingLocalBuriedPointType.java
deleted file mode 100644
index 340a46865a..0000000000
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/OpenTracingLocalBuriedPointType.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder;
-
-import com.a.eye.skywalking.api.IBuriedPointType;
-
-/**
- * @author zhangxin
- */
-public enum OpenTracingLocalBuriedPointType implements IBuriedPointType {
- INSTANCE;
-
- @Override
- public String getTypeName() {
- return "OT";
- }
-
- @Override
- public CallType getCallType() {
- return CallType.LOCAL;
- }
-}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/SkyWalkingSpanBuilderActivation.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/SkyWalkingSpanBuilderActivation.java
deleted file mode 100644
index 7d79c3d1cd..0000000000
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/SkyWalkingSpanBuilderActivation.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder;
-
-import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
-import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
-import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
-
-import net.bytebuddy.description.method.MethodDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-
-import static net.bytebuddy.matcher.ElementMatchers.named;
-import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
-
-/**
- * Created by xin on 2017/1/16.
- */
-public class SkyWalkingSpanBuilderActivation extends ClassInstanceMethodsEnhancePluginDefine {
- @Override
- protected String enhanceClassName() {
- return "com.a.eye.skywalking.toolkit.opentracing.SkyWalkingSpanBuilder";
- }
-
- @Override
- protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return new ConstructorInterceptPoint[]{
- new ConstructorInterceptPoint() {
- @Override
- public ElementMatcher getConstructorMatcher() {
- return takesArguments(String.class);
- }
-
- @Override
- public String getConstructorInterceptor() {
- return "com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder.interceptor.SpanBuilderNewInstanceInterceptor";
- }
- }
- };
- }
-
- @Override
- protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
- return new InstanceMethodsInterceptPoint[]{
- new InstanceMethodsInterceptPoint() {
- @Override
- public ElementMatcher getMethodsMatcher() {
- return named("withTag");
- }
-
- @Override
- public String getMethodsInterceptor() {
- return "com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder.interceptor.SpanBuilderWithTagInterceptor";
- }
- },
- new InstanceMethodsInterceptPoint() {
- @Override
- public ElementMatcher getMethodsMatcher() {
- return named("withStartTimestamp");
- }
-
- @Override
- public String getMethodsInterceptor() {
- return "com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder.interceptor.SpanBuilderWithStartTimeInterceptor";
- }
- },
- new InstanceMethodsInterceptPoint() {
- @Override
- public ElementMatcher getMethodsMatcher() {
- return named("start");
- }
-
- @Override
- public String getMethodsInterceptor() {
- return "com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder.interceptor.SpanBuilderStartInterceptor";
- }
- }
- };
- }
-}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderNewInstanceInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderNewInstanceInterceptor.java
deleted file mode 100644
index 6b0b56dd57..0000000000
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderNewInstanceInterceptor.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder.interceptor;
-
-import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceConstructorInterceptor;
-
-public class SpanBuilderNewInstanceInterceptor implements InstanceConstructorInterceptor {
-
- public static final String OPERATION_NAME = "operationName";
-
- @Override
- public void onConstruct(EnhancedClassInstanceContext context, ConstructorInvokeContext interceptorContext) {
- context.set(OPERATION_NAME, interceptorContext.allArguments()[0]);
- }
-}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderStartInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderStartInterceptor.java
deleted file mode 100644
index 70846c7e0f..0000000000
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderStartInterceptor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder.interceptor;
-
-import com.a.eye.skywalking.invoke.monitor.LocalMethodInvokeMonitor;
-import com.a.eye.skywalking.model.Identification;
-import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
-import com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder.OpenTracingLocalBuriedPointType;
-
-import java.util.Map;
-
-/**
- * @author zhangxin
- */
-public class SpanBuilderStartInterceptor implements InstanceMethodsAroundInterceptor {
-
- public static final String START_TIME = "startTimestamp";
- public static final String OPERATION_NAME = "operationName";
- public static final String TAGS = "tags";
-
- @Override
- public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
-
- Long startTime = fetchStartTime(context);
- String operationName = (String) context.get(OPERATION_NAME);
- Identification.IdentificationBuilder builder = Identification.newBuilder().viewPoint(operationName)
- .spanType(OpenTracingLocalBuriedPointType.INSTANCE);
-
- if (startTime != null){
- builder.startTime(startTime);
- }
-
- Map tags = (Map) context.get(TAGS);
- if (tags != null) {
- for (Map.Entry tag : tags.entrySet()) {
- builder.tag(tag.getKey(), tag.getValue());
- }
- }
-
- new LocalMethodInvokeMonitor().beforeInvoke(builder.build());
- }
-
- private Long fetchStartTime(EnhancedClassInstanceContext context) {
- Object startTime = context.get(START_TIME);
- if (startTime != null){
- return (Long) startTime;
- }
-
- return null;
- }
-
- @Override
- public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
- return ret;
- }
-
- @Override
- public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
-
- }
-}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderWithStartTimeInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderWithStartTimeInterceptor.java
deleted file mode 100644
index 1071743bc1..0000000000
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderWithStartTimeInterceptor.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder.interceptor;
-
-import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
-
-/**
- * Created by xin on 2017/1/16.
- */
-public class SpanBuilderWithStartTimeInterceptor implements InstanceMethodsAroundInterceptor {
-
- public static final String START_TIME = "startTimestamp";
-
- @Override
- public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
- context.set(START_TIME, interceptorContext.allArguments()[0]);
- }
-
- @Override
- public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
- return ret;
- }
-
- @Override
- public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
-
- }
-}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderWithTagInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderWithTagInterceptor.java
deleted file mode 100644
index 6fddea0c77..0000000000
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/spanbuilder/interceptor/SpanBuilderWithTagInterceptor.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder.interceptor;
-
-import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by xin on 2017/1/16.
- */
-public class SpanBuilderWithTagInterceptor implements InstanceMethodsAroundInterceptor {
-
- public static final String TAGS = "tags";
-
- @Override
- public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
- Map contextTags = (Map) context.get(TAGS);
- if (!context.isContain(TAGS)){
- contextTags = new HashMap();
- context.set(TAGS, contextTags);
- }
-
- contextTags.put((String) interceptorContext.allArguments()[0], String.valueOf(interceptorContext
- .allArguments()[1]));
- }
-
- @Override
- public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
- return ret;
- }
-
- @Override
- public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
- // Do nothing
- }
-}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/SkyWalkingTracerActivation.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/SkyWalkingTracerActivation.java
index 767e1d9da9..ed496a0399 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/SkyWalkingTracerActivation.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/SkyWalkingTracerActivation.java
@@ -1,14 +1,14 @@
package com.a.eye.skywalking.toolkit.activation.opentracing.tracer;
-import com.a.eye.skywalking.plugin.interceptor.ConstructorInterceptPoint;
+import com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint;
import com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint;
-import com.a.eye.skywalking.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import java.nio.ByteBuffer;
-import static com.a.eye.skywalking.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
+import static com.a.eye.skywalking.api.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessByteBufferContextInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessByteBufferContextInterceptor.java
index 8650449e28..f8c978c388 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessByteBufferContextInterceptor.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessByteBufferContextInterceptor.java
@@ -1,18 +1,19 @@
package com.a.eye.skywalking.toolkit.activation.opentracing.tracer.interceptor;
-import com.a.eye.skywalking.api.Tracing;
-import com.a.eye.skywalking.model.RefContext;
+import com.a.eye.skywalking.api.context.ContextCarrier;
+import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
+import com.a.eye.skywalking.toolkit.opentracing.SkyWalkingTracer;
+import io.opentracing.propagation.TextMap;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
/**
- *
- * @author zhangxin
+ * Intercept {@link SkyWalkingTracer#extractCrossProcessPropagationContextData(TextMap)}
*/
public class TracerExtractCrossProcessByteBufferContextInterceptor implements InstanceMethodsAroundInterceptor {
@Override
@@ -24,7 +25,11 @@ public class TracerExtractCrossProcessByteBufferContextInterceptor implements In
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
ByteBuffer byteBuffer = (ByteBuffer) interceptorContext.allArguments()[0];
String contextDataStr = new String(byteBuffer.array(), Charset.forName("UTF-8"));
- Tracing.initRefContext(new RefContext(contextDataStr));
+
+ ContextCarrier carrier = new ContextCarrier();
+ carrier.deserialize(contextDataStr);
+
+ ContextManager.INSTANCE.extract(carrier);
return ret;
}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessTextMapContextInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessTextMapContextInterceptor.java
index 729c555f56..ca1e71c98d 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessTextMapContextInterceptor.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerExtractCrossProcessTextMapContextInterceptor.java
@@ -1,50 +1,49 @@
package com.a.eye.skywalking.toolkit.activation.opentracing.tracer.interceptor;
-import com.a.eye.skywalking.api.Tracing;
-import com.a.eye.skywalking.model.RefContext;
+import com.a.eye.skywalking.api.context.ContextCarrier;
+import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
-
+import com.a.eye.skywalking.toolkit.opentracing.SkyWalkingTracer;
+import io.opentracing.propagation.TextMap;
import java.util.Iterator;
import java.util.Map;
-import io.opentracing.propagation.TextMap;
-
/**
- *
- * @author zhangxin
+ * Intercept {@link SkyWalkingTracer#extractCrossProcessPropagationContextData(TextMap)}
*/
public class TracerExtractCrossProcessTextMapContextInterceptor implements InstanceMethodsAroundInterceptor {
-
public static final String SKY_WALKING_TRACING_NAME = "SkyWalking-TRACING-NAME";
@Override
- public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
+ public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext,
+ MethodInterceptResult result) {
// Do nothing
}
@Override
- public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
- TextMap textMap = (TextMap) interceptorContext.allArguments()[0];
+ public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext,
+ Object ret) {
+ TextMap textMap = (TextMap)interceptorContext.allArguments()[0];
Iterator> iterator = textMap.iterator();
- while (iterator.hasNext()){
+ while (iterator.hasNext()) {
Map.Entry entry = iterator.next();
- if (SKY_WALKING_TRACING_NAME.equals(entry.getKey())){
- try {
- Tracing.initRefContext(new RefContext(entry.getValue()));
- }catch (Throwable e){
- // do something
- }
+ if (SKY_WALKING_TRACING_NAME.equals(entry.getKey())) {
+ ContextCarrier carrier = new ContextCarrier();
+ carrier.deserialize(entry.getValue());
+
+ ContextManager.INSTANCE.extract(carrier);
}
}
return ret;
}
@Override
- public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
+ public void handleMethodException(Throwable t, EnhancedClassInstanceContext context,
+ InstanceMethodInvokeContext interceptorContext) {
}
}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerFormatCrossProcessContextInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerFormatCrossProcessContextInterceptor.java
index bf6a4880f8..ed87a94d07 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerFormatCrossProcessContextInterceptor.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/opentracing/tracer/interceptor/TracerFormatCrossProcessContextInterceptor.java
@@ -1,15 +1,15 @@
package com.a.eye.skywalking.toolkit.activation.opentracing.tracer.interceptor;
-import com.a.eye.skywalking.api.Tracing;
-import com.a.eye.skywalking.model.ContextData;
-import com.a.eye.skywalking.model.Span;
+import com.a.eye.skywalking.api.context.ContextCarrier;
+import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext;
-import com.a.eye.skywalking.plugin.interceptor.enhance.InstanceMethodInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
+import com.a.eye.skywalking.toolkit.opentracing.SkyWalkingTracer;
/**
- * @author zhangxin
+ * Intercept {@link SkyWalkingTracer#formatCrossProcessPropagationContextData()}
*/
public class TracerFormatCrossProcessContextInterceptor implements InstanceMethodsAroundInterceptor {
@Override
@@ -19,23 +19,13 @@ public class TracerFormatCrossProcessContextInterceptor implements InstanceMetho
@Override
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
- Span span = Tracing.getCurrentSpan();
- if (span != null) {
- return new ContextData(span.getTraceId(), generateSubParentLevelId(span), span.getRouteKey()).toString();
- }
- return ret;
+ ContextCarrier carrier = new ContextCarrier();
+ ContextManager.INSTANCE.inject(carrier);
+ return carrier.serialize();
}
@Override
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext) {
}
-
- private String generateSubParentLevelId(Span spanData) {
- if (spanData.getParentLevel() == null || spanData.getParentLevel().length() == 0) {
- return spanData.getLevelId() + "";
- }
-
- return spanData.getParentLevel() + "." + spanData.getLevelId();
- }
}
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/resources/skywalking-plugin.def b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/resources/skywalking-plugin.def
index bad4288c74..a528db98f9 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/resources/skywalking-plugin.def
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-opentracing-activation/src/main/resources/skywalking-plugin.def
@@ -1,3 +1,2 @@
com.a.eye.skywalking.toolkit.activation.opentracing.span.SkyWalkingSpanActivation
-com.a.eye.skywalking.toolkit.activation.opentracing.spanbuilder.SkyWalkingSpanBuilderActivation
-com.a.eye.skywalking.toolkit.activation.opentracing.tracer.SkyWalkingTracerActivation
\ No newline at end of file
+com.a.eye.skywalking.toolkit.activation.opentracing.tracer.SkyWalkingTracerActivation
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextActivation.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextActivation.java
index b9ef99696b..8345c1865d 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextActivation.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextActivation.java
@@ -1,7 +1,7 @@
package com.a.eye.skywalking.toolkit.activation.trace;
-import com.a.eye.skywalking.plugin.interceptor.StaticMethodsInterceptPoint;
-import com.a.eye.skywalking.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine;
+import com.a.eye.skywalking.api.plugin.interceptor.StaticMethodsInterceptPoint;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
diff --git a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextInterceptor.java b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextInterceptor.java
index 89f43ac7d6..4ab6b4ecf8 100644
--- a/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextInterceptor.java
+++ b/skywalking-sniffer/skywalking-toolkit-activation/skywalking-toolkit-trace-context-activation/src/main/java/com/a/eye/skywalking/toolkit/activation/trace/TraceContextInterceptor.java
@@ -1,15 +1,15 @@
package com.a.eye.skywalking.toolkit.activation.trace;
-import com.a.eye.skywalking.api.Tracing;
+import com.a.eye.skywalking.api.context.ContextCarrier;
+import com.a.eye.skywalking.api.context.ContextManager;
import com.a.eye.skywalking.api.logging.api.ILog;
import com.a.eye.skywalking.api.logging.api.LogManager;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult;
-import com.a.eye.skywalking.plugin.interceptor.enhance.MethodInvokeContext;
+import com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.StaticMethodInvokeContext;
import com.a.eye.skywalking.api.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
/**
- *
*
* Created by xin on 2016/12/15.
*/
@@ -24,7 +24,9 @@ public class TraceContextInterceptor implements StaticMethodsAroundInterceptor {
@Override
public Object afterMethod(StaticMethodInvokeContext interceptorContext, Object ret) {
- return Tracing.getTraceId();
+ ContextCarrier carrier = new ContextCarrier();
+ ContextManager.INSTANCE.inject(carrier);
+ return carrier.getTraceSegmentId();
}
@Override