Finish the refactor of agent-core.
This commit is contained in:
parent
48b2164f33
commit
1fd449cddc
|
|
@ -9,8 +9,8 @@ import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
|||
import org.skywalking.apm.util.StringUtil;
|
||||
|
||||
/**
|
||||
* {@link ContextCarrier} is a data carrier of {@link TracerContext}.
|
||||
* It holds the snapshot (current state) of {@link TracerContext}.
|
||||
* {@link ContextCarrier} is a data carrier of {@link TracingContext}.
|
||||
* It holds the snapshot (current state) of {@link TracingContext}.
|
||||
* <p>
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
|
|
@ -20,20 +20,10 @@ public class ContextCarrier implements Serializable {
|
|||
*/
|
||||
private String traceSegmentId;
|
||||
|
||||
/**
|
||||
* {@link Span#spanId}
|
||||
*/
|
||||
private int spanId = -1;
|
||||
|
||||
/**
|
||||
* {@link TraceSegment#applicationCode}
|
||||
*/
|
||||
private String applicationCode;
|
||||
|
||||
/**
|
||||
* Either {@link Span#peerHost} + {@link Span#port} or {@link Span#peers},
|
||||
* depend on which one of them is valid.
|
||||
*/
|
||||
private String peerHost;
|
||||
|
||||
/**
|
||||
|
|
@ -120,6 +110,10 @@ public class ContextCarrier implements Serializable {
|
|||
this.applicationCode = applicationCode;
|
||||
}
|
||||
|
||||
public void setApplicationId(int applicationId) {
|
||||
this.applicationCode = applicationId + "";
|
||||
}
|
||||
|
||||
public String getPeerHost() {
|
||||
return peerHost;
|
||||
}
|
||||
|
|
@ -128,6 +122,10 @@ public class ContextCarrier implements Serializable {
|
|||
this.peerHost = peerHost;
|
||||
}
|
||||
|
||||
public void setPeerId(int peerId) {
|
||||
this.peerHost = peerId + "";
|
||||
}
|
||||
|
||||
public List<DistributedTraceId> getDistributedTraceIds() {
|
||||
return distributedTraceIds;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,12 @@ import org.skywalking.apm.agent.core.sampling.SamplingService;
|
|||
import org.skywalking.apm.util.StringUtil;
|
||||
|
||||
/**
|
||||
* {@link TracerContext} controls the whole context of {@link TraceSegment}. Any {@link TraceSegment} relates to
|
||||
* {@link ContextManager} controls the whole context of {@link TraceSegment}. Any {@link TraceSegment} relates to
|
||||
* single-thread, so this context use {@link ThreadLocal} to maintain the context, and make sure, since a {@link
|
||||
* TraceSegment} starts, all ChildOf spans are in the same context. <p> What is 'ChildOf'? {@see
|
||||
* https://github.com/opentracing/specification/blob/master/specification.md#references-between-spans} <p> Also, {@link
|
||||
* ContextManager} delegates to all {@link TracerContext}'s major methods: {@link TracerContext#createSpan(String,
|
||||
* boolean)}, {@link TracerContext#activeSpan()}, {@link AbstractTracerContext#stopSpan(org.skywalking.apm.agent.core.context.trace.AbstractSpan)}
|
||||
* <p>
|
||||
* https://github.com/opentracing/specification/blob/master/specification.md#references-between-spans}
|
||||
*
|
||||
* <p> Also, {@link ContextManager} delegates to all {@link AbstractTracerContext}'s major methods.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
|
|
@ -37,10 +36,7 @@ public class ContextManager implements TracingContextListener, BootService, Igno
|
|||
if (forceSampling || samplingService.trySampling()) {
|
||||
context = new TracingContext();
|
||||
} else {
|
||||
/**
|
||||
* {@link ContextType#AGGREGATED_TRACING}
|
||||
* TODO
|
||||
*/
|
||||
context = new IgnoredTracerContext();
|
||||
}
|
||||
}
|
||||
CONTEXT.set(context);
|
||||
|
|
@ -90,7 +86,9 @@ public class ContextManager implements TracingContextListener, BootService, Igno
|
|||
throw new IllegalArgumentException("Injectable can't be null.");
|
||||
}
|
||||
AbstractTracerContext context = getOrCreate(operationName, false);
|
||||
return context.createSpan(operationName, SpanType.EXIT);
|
||||
AbstractSpan span = context.createSpan(operationName, SpanType.EXIT);
|
||||
context.inject(injectable.getCarrier());
|
||||
return span;
|
||||
}
|
||||
|
||||
public static AbstractSpan activeSpan() {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
|
||||
import org.skywalking.apm.agent.core.context.trace.NoopSpan;
|
||||
import org.skywalking.apm.agent.core.context.trace.SpanType;
|
||||
|
||||
/**
|
||||
* The <code>IgnoredTracerContext</code> represent a context should be ignored.
|
||||
|
|
@ -37,14 +38,14 @@ public class IgnoredTracerContext implements AbstractTracerContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSpan createSpan(String operationName, boolean isLeaf) {
|
||||
stackDepth++;
|
||||
return NOOP_SPAN;
|
||||
public AbstractSpan createSpan(String operationName, SpanType spanType) {
|
||||
return createSpan(operationName, spanType, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSpan createSpan(String operationName, long startTime, boolean isLeaf) {
|
||||
return createSpan(operationName, isLeaf);
|
||||
public AbstractSpan createSpan(String operationName, SpanType spanType, Injectable injectable) {
|
||||
stackDepth++;
|
||||
return NOOP_SPAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -60,11 +61,6 @@ public class IgnoredTracerContext implements AbstractTracerContext {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSpan(AbstractSpan span, Long endTime) {
|
||||
stopSpan(span);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,7 @@ package org.skywalking.apm.agent.core.context;
|
|||
* @author wusheng
|
||||
*/
|
||||
public interface Injectable {
|
||||
/**
|
||||
* @param injectedCarrier notify the <code>Injectable</code> the {@link ContextCarrier} has been injected.
|
||||
*/
|
||||
void notify(ContextCarrier injectedCarrier);
|
||||
ContextCarrier getCarrier();
|
||||
|
||||
/**
|
||||
* @return peer, represent ipv4, ipv6, hostname, or cluster addresses list.
|
||||
|
|
|
|||
|
|
@ -1,293 +0,0 @@
|
|||
package org.skywalking.apm.agent.core.context;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.agent.core.sampling.SamplingService;
|
||||
|
||||
/**
|
||||
* {@link TracerContext} maintains the context.
|
||||
* You manipulate (create/finish/get) spans and (inject/extract) context.
|
||||
* <p>
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public final class TracerContext implements AbstractTracerContext {
|
||||
private SamplingService samplingService;
|
||||
|
||||
private TraceSegment segment;
|
||||
|
||||
/**
|
||||
* Active spans stored in a Stack, usually called 'ActiveSpanStack'.
|
||||
* This {@link LinkedList} is the in-memory storage-structure.
|
||||
* <p>
|
||||
* I use {@link LinkedList#removeLast()}, {@link LinkedList#addLast(Object)} and {@link LinkedList#last} instead of
|
||||
* {@link #pop()}, {@link #push(Span)}, {@link #peek()}
|
||||
*/
|
||||
private LinkedList<Span> activeSpanStack = new LinkedList<Span>();
|
||||
|
||||
private int spanIdGenerator;
|
||||
|
||||
/**
|
||||
* Create a {@link TraceSegment} and init {@link #spanIdGenerator} as 0;
|
||||
*/
|
||||
TracerContext() {
|
||||
this.segment = new TraceSegment(Config.Agent.APPLICATION_CODE);
|
||||
this.spanIdGenerator = 0;
|
||||
if (samplingService == null) {
|
||||
samplingService = ServiceManager.INSTANCE.findService(SamplingService.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new span, as an active span, by the given operationName
|
||||
*
|
||||
* @param operationName {@link Span#operationName}
|
||||
* @return the new active span.
|
||||
*/
|
||||
public AbstractSpan createSpan(String operationName, boolean isLeaf) {
|
||||
return this.createSpan(operationName, System.currentTimeMillis(), isLeaf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new span, as an active span, by the given operationName and startTime;
|
||||
*
|
||||
* @param operationName {@link Span#operationName}
|
||||
* @param startTime {@link Span#startTime}
|
||||
* @param isLeaf is true, if the span is a leaf in trace tree.
|
||||
* @return
|
||||
*/
|
||||
public AbstractSpan createSpan(String operationName, long startTime, boolean isLeaf) {
|
||||
Span parentSpan = peek();
|
||||
Span span;
|
||||
if (parentSpan == null) {
|
||||
if (operationName != null) {
|
||||
int suffixIdx = operationName.lastIndexOf(".");
|
||||
if (suffixIdx > -1 && Config.Agent.IGNORE_SUFFIX.contains(operationName.substring(suffixIdx))) {
|
||||
ContextManager.ContextSwitcher.INSTANCE.toNew(new IgnoredTracerContext(1));
|
||||
return ContextManager.activeSpan();
|
||||
}
|
||||
}
|
||||
|
||||
if (isLeaf) {
|
||||
span = new LeafSpan(spanIdGenerator++, operationName, startTime);
|
||||
} else {
|
||||
span = new Span(spanIdGenerator++, operationName, startTime);
|
||||
}
|
||||
push(span);
|
||||
} else {
|
||||
/**
|
||||
* Don't have ref yet, means this isn't part of distributed trace.
|
||||
* Use sampling mechanism
|
||||
* Only check this on the second span,
|
||||
* because the {@link #extract(ContextCarrier)} invoke before create the second span.
|
||||
*/
|
||||
if (spanIdGenerator == 1) {
|
||||
if (segment.hasRef()) {
|
||||
samplingService.forceSampled();
|
||||
} else {
|
||||
if (!samplingService.trySampling()) {
|
||||
/**
|
||||
* Don't sample this trace.
|
||||
* Now, switch this trace as an {@link IgnoredTracerContext},
|
||||
* further more, we will provide an analytic tracer context for all metrics in this trace.
|
||||
*/
|
||||
ContextManager.ContextSwitcher.INSTANCE.toNew(new IgnoredTracerContext(2));
|
||||
return ContextManager.activeSpan();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parentSpan.isLeaf()) {
|
||||
span = parentSpan;
|
||||
LeafSpan leafSpan = (LeafSpan)span;
|
||||
leafSpan.push();
|
||||
} else {
|
||||
if (isLeaf) {
|
||||
span = new LeafSpan(spanIdGenerator++, parentSpan, operationName, startTime);
|
||||
} else {
|
||||
span = new Span(spanIdGenerator++, parentSpan, operationName, startTime);
|
||||
}
|
||||
push(span);
|
||||
}
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the active span of current context.
|
||||
*/
|
||||
public AbstractSpan activeSpan() {
|
||||
Span span = peek();
|
||||
if (span == null) {
|
||||
throw new IllegalStateException("No active span.");
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the span. And finish the {@link #segment} if all {@link #activeSpanStack} elements are finished.
|
||||
*
|
||||
* @param span to finish. It must the the top element of {@link #activeSpanStack}.
|
||||
*/
|
||||
public void stopSpan(AbstractSpan span) {
|
||||
stopSpan(span, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current trace id.
|
||||
*/
|
||||
public String getGlobalTraceId() {
|
||||
return segment.getRelatedGlobalTraces().get(0).get();
|
||||
}
|
||||
|
||||
public void stopSpan(AbstractSpan span, Long endTime) {
|
||||
Span lastSpan = peek();
|
||||
if (lastSpan.isLeaf()) {
|
||||
LeafSpan leafSpan = (LeafSpan)lastSpan;
|
||||
leafSpan.pop();
|
||||
if (!leafSpan.isFinished()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (lastSpan == span) {
|
||||
pop().finish(segment, endTime);
|
||||
} else {
|
||||
throw new IllegalStateException("Stopping the unexpected span = " + span);
|
||||
}
|
||||
|
||||
if (activeSpanStack.isEmpty()) {
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
this.segment = null;
|
||||
this.activeSpanStack = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish this context, and notify all {@link TracingContextListener}s, managed by {@link ListenerManager}
|
||||
*/
|
||||
private void finish() {
|
||||
TraceSegment finishedSegment = segment.finish();
|
||||
/**
|
||||
* Recheck the segment if the segment contains only one span.
|
||||
* Because in the runtime, can't sure this segment is part of distributed trace.
|
||||
*
|
||||
* @see {@link #createSpan(String, long, boolean)}
|
||||
*/
|
||||
if (!segment.hasRef() && segment.isSingleSpanSegment()) {
|
||||
if (!samplingService.trySampling()) {
|
||||
finishedSegment.setIgnore(true);
|
||||
}
|
||||
}
|
||||
ListenerManager.notifyFinish(finishedSegment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give a snapshot of this {@link TracerContext},
|
||||
* and save current state to the given {@link ContextCarrier}.
|
||||
*
|
||||
* @param carrier holds the snapshot
|
||||
*/
|
||||
public void inject(ContextCarrier carrier) {
|
||||
carrier.setTraceSegmentId(this.segment.getTraceSegmentId());
|
||||
Span span = (Span)this.activeSpan();
|
||||
carrier.setSpanId(span.getSpanId());
|
||||
carrier.setApplicationCode(Config.Agent.APPLICATION_CODE);
|
||||
String host = span.getPeerHost();
|
||||
if (host != null) {
|
||||
Integer port = span.getPort();
|
||||
carrier.setPeerHost(host + ":" + port);
|
||||
} else {
|
||||
carrier.setPeerHost(span.getPeers());
|
||||
}
|
||||
carrier.setDistributedTraceIds(this.segment.getRelatedGlobalTraces());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ref this {@link ContextCarrier} to this {@link TraceSegment}
|
||||
*
|
||||
* @param carrier holds the snapshot, if get this {@link ContextCarrier} from remote, make sure {@link
|
||||
* ContextCarrier#deserialize(String)} called.
|
||||
*/
|
||||
public void extract(ContextCarrier carrier) {
|
||||
if (carrier.isValid()) {
|
||||
this.segment.ref(getRef(carrier));
|
||||
this.segment.relatedGlobalTraces(carrier.getDistributedTraceIds());
|
||||
}
|
||||
}
|
||||
|
||||
private TraceSegmentRef getRef(ContextCarrier carrier) {
|
||||
TraceSegmentRef ref = new TraceSegmentRef();
|
||||
ref.setTraceSegmentId(carrier.getTraceSegmentId());
|
||||
ref.setSpanId(carrier.getSpanId());
|
||||
ref.setApplicationCode(carrier.getApplicationCode());
|
||||
ref.setPeerHost(carrier.getPeerHost());
|
||||
return ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the top element of 'ActiveSpanStack', and remove it.
|
||||
*/
|
||||
private Span pop() {
|
||||
return activeSpanStack.removeLast();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new Span at the top of 'ActiveSpanStack'
|
||||
*
|
||||
* @param span
|
||||
*/
|
||||
private void push(Span span) {
|
||||
activeSpanStack.addLast(span);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the top element of 'ActiveSpanStack' only.
|
||||
*/
|
||||
private Span peek() {
|
||||
if (activeSpanStack.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return activeSpanStack.getLast();
|
||||
}
|
||||
|
||||
public static class ListenerManager {
|
||||
private static List<TracingContextListener> LISTENERS = new LinkedList<TracingContextListener>();
|
||||
|
||||
/**
|
||||
* Add the given {@link TracingContextListener} to {@link #LISTENERS} list.
|
||||
*
|
||||
* @param listener the new listener.
|
||||
*/
|
||||
public static synchronized void add(TracingContextListener listener) {
|
||||
LISTENERS.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the {@link ListenerManager} about the given {@link TraceSegment} have finished.
|
||||
* And trigger {@link ListenerManager} to notify all {@link #LISTENERS} 's
|
||||
* {@link TracingContextListener#afterFinished(TraceSegment)}
|
||||
*
|
||||
* @param finishedSegment
|
||||
*/
|
||||
static void notifyFinish(TraceSegment finishedSegment) {
|
||||
for (TracingContextListener listener : LISTENERS) {
|
||||
listener.afterFinished(finishedSegment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the given {@link TracingContextListener}
|
||||
*/
|
||||
public static synchronized void remove(TracingContextListener listener) {
|
||||
LISTENERS.remove(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,9 @@ import org.skywalking.apm.agent.core.context.trace.LocalSpan;
|
|||
import org.skywalking.apm.agent.core.context.trace.SpanType;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.agent.core.dictionary.DictionaryManager;
|
||||
import org.skywalking.apm.agent.core.dictionary.DictionaryUtil;
|
||||
import org.skywalking.apm.agent.core.dictionary.PossibleFound;
|
||||
import org.skywalking.apm.agent.core.sampling.SamplingService;
|
||||
|
||||
/**
|
||||
|
|
@ -42,12 +45,29 @@ public class TracingContext implements AbstractTracerContext {
|
|||
|
||||
@Override
|
||||
public void inject(ContextCarrier carrier) {
|
||||
AbstractTracingSpan span = this.activeSpan();
|
||||
if (span.isExit()) {
|
||||
throw new IllegalStateException("Inject can be done only in Exit Span");
|
||||
}
|
||||
ExitSpan exitSpan = (ExitSpan)span;
|
||||
|
||||
carrier.setTraceSegmentId(this.segment.getTraceSegmentId());
|
||||
carrier.setSpanId(span.getSpanId());
|
||||
|
||||
carrier.setApplicationId(segment.getApplicationId());
|
||||
|
||||
if (DictionaryUtil.isNull(exitSpan.getPeerId())) {
|
||||
carrier.setPeerHost(exitSpan.getPeer());
|
||||
} else {
|
||||
carrier.setPeerId(exitSpan.getPeerId());
|
||||
}
|
||||
|
||||
carrier.setDistributedTraceIds(this.segment.getRelatedGlobalTraces());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extract(ContextCarrier carrier) {
|
||||
this.segment.ref(getRef(carrier));
|
||||
this.segment.ref(new TraceSegmentRef(carrier));
|
||||
this.segment.relatedGlobalTraces(carrier.getDistributedTraceIds());
|
||||
}
|
||||
|
||||
|
|
@ -69,23 +89,71 @@ public class TracingContext implements AbstractTracerContext {
|
|||
return span.start();
|
||||
}
|
||||
|
||||
private AbstractTracingSpan createByType(int spanId, int parentSpanId,
|
||||
String operationName, SpanType spanType,
|
||||
String peerHost, AbstractTracingSpan parentSpan) {
|
||||
private AbstractTracingSpan createByType(final int spanId, final int parentSpanId,
|
||||
final String operationName, SpanType spanType,
|
||||
final String peerHost, AbstractTracingSpan parentSpan) {
|
||||
switch (spanType) {
|
||||
case LOCAL:
|
||||
return new LocalSpan(spanId, parentSpanId, operationName);
|
||||
return (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
|
||||
.find(segment.getApplicationId(), operationName)
|
||||
.doInCondition(new PossibleFound.FoundAndObtain() {
|
||||
@Override
|
||||
public Object doProcess(int operationId) {
|
||||
return new LocalSpan(spanId, parentSpanId, operationId);
|
||||
}
|
||||
}, new PossibleFound.NotFoundAndObtain() {
|
||||
@Override
|
||||
public Object doProcess() {
|
||||
return new LocalSpan(spanId, parentSpanId, operationName);
|
||||
}
|
||||
});
|
||||
case EXIT:
|
||||
if (parentSpan != null && parentSpan.isExit()) {
|
||||
return parentSpan;
|
||||
} else {
|
||||
return new ExitSpan(spanId, parentSpanId, operationName, peerHost);
|
||||
return (AbstractTracingSpan)DictionaryManager.findApplicationCodeSection()
|
||||
.find(peerHost).doInCondition(
|
||||
new PossibleFound.FoundAndObtain() {
|
||||
@Override
|
||||
public Object doProcess(final int applicationId) {
|
||||
return DictionaryManager.findOperationNameCodeSection()
|
||||
.find(applicationId, operationName)
|
||||
.doInCondition(
|
||||
new PossibleFound.FoundAndObtain() {
|
||||
@Override
|
||||
public Object doProcess(int peerId) {
|
||||
return new ExitSpan(spanId, parentSpanId, applicationId, peerId);
|
||||
}
|
||||
}, new PossibleFound.NotFoundAndObtain() {
|
||||
@Override
|
||||
public Object doProcess() {
|
||||
return new ExitSpan(spanId, parentSpanId, applicationId, peerHost);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
new PossibleFound.NotFoundAndObtain() {
|
||||
@Override
|
||||
public Object doProcess() {
|
||||
return new ExitSpan(spanId, parentSpanId, operationName, peerHost);
|
||||
}
|
||||
});
|
||||
}
|
||||
case ENTRY:
|
||||
if (parentSpan.isEntry()) {
|
||||
return parentSpan;
|
||||
} else if (parentSpan == null) {
|
||||
return new EntrySpan(spanId, parentSpanId, operationName);
|
||||
return (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
|
||||
.find(segment.getApplicationId(), operationName)
|
||||
.doInCondition(new PossibleFound.FoundAndObtain() {
|
||||
@Override public Object doProcess(int operationId) {
|
||||
return new EntrySpan(spanId, parentSpanId, operationId);
|
||||
}
|
||||
}, new PossibleFound.NotFoundAndObtain() {
|
||||
@Override public Object doProcess() {
|
||||
return new EntrySpan(spanId, parentSpanId, operationName);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
throw new IllegalStateException("The Entry Span can't be the child of Non-Entry Span");
|
||||
}
|
||||
|
|
@ -121,7 +189,7 @@ public class TracingContext implements AbstractTracerContext {
|
|||
|
||||
/**
|
||||
* Finish this context, and notify all {@link TracingContextListener}s, managed by {@link
|
||||
* TracerContext.ListenerManager}
|
||||
* TracingContext.ListenerManager}
|
||||
*/
|
||||
private void finish() {
|
||||
TraceSegment finishedSegment = segment.finish();
|
||||
|
|
@ -136,7 +204,7 @@ public class TracingContext implements AbstractTracerContext {
|
|||
finishedSegment.setIgnore(true);
|
||||
}
|
||||
}
|
||||
TracerContext.ListenerManager.notifyFinish(finishedSegment);
|
||||
TracingContext.ListenerManager.notifyFinish(finishedSegment);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -158,8 +226,8 @@ public class TracingContext implements AbstractTracerContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Notify the {@link TracerContext.ListenerManager} about the given {@link TraceSegment} have finished.
|
||||
* And trigger {@link TracerContext.ListenerManager} to notify all {@link #LISTENERS} 's
|
||||
* Notify the {@link TracingContext.ListenerManager} about the given {@link TraceSegment} have finished.
|
||||
* And trigger {@link TracingContext.ListenerManager} to notify all {@link #LISTENERS} 's
|
||||
* {@link TracingContextListener#afterFinished(TraceSegment)}
|
||||
*
|
||||
* @param finishedSegment
|
||||
|
|
@ -204,13 +272,4 @@ public class TracingContext implements AbstractTracerContext {
|
|||
}
|
||||
return activeSpanStack.getLast();
|
||||
}
|
||||
|
||||
private TraceSegmentRef getRef(ContextCarrier carrier) {
|
||||
TraceSegmentRef ref = new TraceSegmentRef();
|
||||
ref.setTraceSegmentId(carrier.getTraceSegmentId());
|
||||
ref.setSpanId(carrier.getSpanId());
|
||||
ref.setApplicationCode(carrier.getApplicationCode());
|
||||
ref.setPeerHost(carrier.getPeerHost());
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
|
||||
|
||||
/**
|
||||
* Do the same thing as {@link StringTag}, just with a {@link Boolean} value.
|
||||
* <p>
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public class BooleanTag extends AbstractTag<Boolean> {
|
||||
|
||||
private boolean defaultValue;
|
||||
|
||||
public BooleanTag(String key, boolean defaultValue) {
|
||||
super(key);
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(AbstractSpan span, Boolean tagValue) {
|
||||
span.setTag(key, tagValue);
|
||||
}
|
||||
|
||||
public boolean defaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
/**
|
||||
* The tag item with String key and Boolean value.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class BooleanTagItem {
|
||||
private String key;
|
||||
private boolean value;
|
||||
|
||||
public BooleanTagItem(String key, boolean value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public boolean getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
|
||||
|
||||
/**
|
||||
* Do the same thing as {@link StringTag}, just with a {@link Integer} value.
|
||||
* <p>
|
||||
* Created by wusheng on 2017/2/18.
|
||||
*/
|
||||
public class IntTag extends AbstractTag<Integer> {
|
||||
public IntTag(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(AbstractSpan span, Integer tagValue) {
|
||||
span.setTag(super.key, tagValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
/**
|
||||
* The tag item with String key and Int value.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class IntTagItem {
|
||||
private String key;
|
||||
private int value;
|
||||
|
||||
public IntTagItem(String key, int value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,6 @@ public class StringTag extends AbstractTag<String> {
|
|||
|
||||
@Override
|
||||
public void set(AbstractSpan span, String tagValue) {
|
||||
span.setTag(key, tagValue);
|
||||
span.tag(key, tagValue);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
package org.skywalking.apm.agent.core.context.tag;
|
||||
|
||||
/**
|
||||
* The tag item with String key and String value.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public final class StringTagItem {
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public StringTagItem(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ public final class Tags {
|
|||
/**
|
||||
* STATUS_CODE records the http status code of the response.
|
||||
*/
|
||||
public static final IntTag STATUS_CODE = new IntTag("status_code");
|
||||
public static final StringTag STATUS_CODE = new StringTag("status_code");
|
||||
|
||||
/**
|
||||
* SPAN_KIND hints at the relationship between spans, e.g. client/server.
|
||||
|
|
@ -71,11 +71,6 @@ public final class Tags {
|
|||
*/
|
||||
public static final StringTag COMPONENT = new StringTag("component");
|
||||
|
||||
/**
|
||||
* ERROR indicates whether a Span ended in an error state.
|
||||
*/
|
||||
public static final BooleanTag ERROR = new BooleanTag("error", false);
|
||||
|
||||
/**
|
||||
* DB_TYPE records database type, such as sql, redis, cassandra and so on.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.util.KeyValuePair;
|
||||
import org.skywalking.apm.agent.core.context.util.ThrowableTransformer;
|
||||
|
||||
/**
|
||||
* The <code>AbstractSpan</code> represents the span's skeleton,
|
||||
|
|
@ -11,39 +7,13 @@ import org.skywalking.apm.agent.core.context.util.ThrowableTransformer;
|
|||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public abstract class AbstractSpan {
|
||||
protected String operationName;
|
||||
/**
|
||||
* The start time of this Span.
|
||||
*/
|
||||
protected long startTime;
|
||||
/**
|
||||
* The end time of this Span.
|
||||
*/
|
||||
protected long endTime;
|
||||
|
||||
/**
|
||||
* Log is a concept from OpenTracing spec.
|
||||
* <p>
|
||||
* {@see https://github.com/opentracing/specification/blob/master/specification.md#log-structured-data}
|
||||
*/
|
||||
protected List<LogDataEntity> logs;
|
||||
|
||||
protected AbstractSpan(String operationName) {
|
||||
this.operationName = operationName;
|
||||
}
|
||||
|
||||
public AbstractSpan start() {
|
||||
this.startTime = System.currentTimeMillis();
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface AbstractSpan {
|
||||
/**
|
||||
* Set a key:value tag on the Span.
|
||||
*
|
||||
* @return this Span instance, for chaining
|
||||
*/
|
||||
public abstract AbstractSpan tag(String key, String value);
|
||||
AbstractSpan tag(String key, String value);
|
||||
|
||||
/**
|
||||
* Record an exception event of the current walltime timestamp.
|
||||
|
|
@ -51,31 +21,22 @@ public abstract class AbstractSpan {
|
|||
* @param t any subclass of {@link Throwable}, which occurs in this span.
|
||||
* @return the Span, for chaining
|
||||
*/
|
||||
public AbstractSpan log(Throwable t) {
|
||||
if (logs == null) {
|
||||
logs = new LinkedList<LogDataEntity>();
|
||||
}
|
||||
logs.add(new LogDataEntity.Builder()
|
||||
.add(new KeyValuePair("event", "error"))
|
||||
.add(new KeyValuePair("error.kind", t.getClass().getName()))
|
||||
.add(new KeyValuePair("message", t.getMessage()))
|
||||
.add(new KeyValuePair("stack", ThrowableTransformer.INSTANCE.convert2String(t, 4000)))
|
||||
.build());
|
||||
return this;
|
||||
}
|
||||
AbstractSpan log(Throwable t);
|
||||
|
||||
void errorOccurred();
|
||||
|
||||
/**
|
||||
* @return true if the actual span is an entry span.
|
||||
*/
|
||||
public abstract boolean isEntry();
|
||||
boolean isEntry();
|
||||
|
||||
/**
|
||||
* @return true if the actual span is a local span.
|
||||
*/
|
||||
public abstract boolean isLocal();
|
||||
boolean isLocal();
|
||||
|
||||
/**
|
||||
* @return true if the actual span is an exit span.
|
||||
*/
|
||||
public abstract boolean isExit();
|
||||
boolean isExit();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package org.skywalking.apm.agent.core.context.trace;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.util.KeyValuePair;
|
||||
import org.skywalking.apm.agent.core.context.util.ThrowableTransformer;
|
||||
import org.skywalking.apm.agent.core.dictionary.DictionaryUtil;
|
||||
|
||||
/**
|
||||
* The <code>AbstractTracingSpan</code> represents a group of {@link AbstractSpan} implementations,
|
||||
|
|
@ -10,17 +12,51 @@ import org.skywalking.apm.agent.core.context.util.KeyValuePair;
|
|||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public abstract class AbstractTracingSpan extends AbstractSpan {
|
||||
public abstract class AbstractTracingSpan implements AbstractSpan {
|
||||
protected int spanId;
|
||||
protected int parentSpanId;
|
||||
protected List<KeyValuePair> tags;
|
||||
protected String operationName;
|
||||
protected int operationId;
|
||||
/**
|
||||
* The start time of this Span.
|
||||
*/
|
||||
protected long startTime;
|
||||
/**
|
||||
* The end time of this Span.
|
||||
*/
|
||||
protected long endTime;
|
||||
/**
|
||||
* Error has occurred in the scope of span.
|
||||
*/
|
||||
protected boolean errorOccurred = false;
|
||||
|
||||
/**
|
||||
* Log is a concept from OpenTracing spec.
|
||||
* <p>
|
||||
* {@see https://github.com/opentracing/specification/blob/master/specification.md#log-structured-data}
|
||||
*/
|
||||
protected List<LogDataEntity> logs;
|
||||
|
||||
protected AbstractTracingSpan(int spanId, int parentSpanId, String operationName) {
|
||||
super(operationName);
|
||||
this.operationName = operationName;
|
||||
this.operationId = DictionaryUtil.nullValue();
|
||||
this.spanId = spanId;
|
||||
this.parentSpanId = parentSpanId;
|
||||
}
|
||||
|
||||
protected AbstractTracingSpan(int spanId, int parentSpanId, int operationId) {
|
||||
this.operationName = null;
|
||||
this.operationId = operationId;
|
||||
this.spanId = spanId;
|
||||
this.parentSpanId = parentSpanId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a key:value tag on the Span.
|
||||
*
|
||||
* @return this Span instance, for chaining
|
||||
*/
|
||||
@Override
|
||||
public AbstractTracingSpan tag(String key, String value) {
|
||||
if (tags == null) {
|
||||
|
|
@ -41,4 +77,40 @@ public abstract class AbstractTracingSpan extends AbstractSpan {
|
|||
owner.archive(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public AbstractSpan start() {
|
||||
this.startTime = System.currentTimeMillis();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record an exception event of the current walltime timestamp.
|
||||
*
|
||||
* @param t any subclass of {@link Throwable}, which occurs in this span.
|
||||
* @return the Span, for chaining
|
||||
*/
|
||||
public AbstractSpan log(Throwable t) {
|
||||
if (logs == null) {
|
||||
logs = new LinkedList<LogDataEntity>();
|
||||
}
|
||||
logs.add(new LogDataEntity.Builder()
|
||||
.add(new KeyValuePair("event", "error"))
|
||||
.add(new KeyValuePair("error.kind", t.getClass().getName()))
|
||||
.add(new KeyValuePair("message", t.getMessage()))
|
||||
.add(new KeyValuePair("stack", ThrowableTransformer.INSTANCE.convert2String(t, 4000)))
|
||||
.build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public void errorOccurred() {
|
||||
this.errorOccurred = true;
|
||||
}
|
||||
|
||||
public int getSpanId() {
|
||||
return spanId;
|
||||
}
|
||||
|
||||
public int getOperationId() {
|
||||
return operationId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,18 @@ package org.skywalking.apm.agent.core.context.trace;
|
|||
*/
|
||||
public class EntrySpan extends AbstractTracingSpan {
|
||||
private int stackDepth;
|
||||
private int currentMaxDepth;
|
||||
|
||||
public EntrySpan(int spanId, int parentSpanId, String operationName) {
|
||||
super(spanId, parentSpanId, operationName);
|
||||
this.stackDepth = 0;
|
||||
this.currentMaxDepth = 0;
|
||||
}
|
||||
|
||||
public EntrySpan(int spanId, int parentSpanId, int operationId) {
|
||||
super(spanId, parentSpanId, operationId);
|
||||
this.stackDepth = 0;
|
||||
this.currentMaxDepth = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -23,7 +31,7 @@ public class EntrySpan extends AbstractTracingSpan {
|
|||
*/
|
||||
@Override
|
||||
public EntrySpan start() {
|
||||
if (++stackDepth == 1) {
|
||||
if ((currentMaxDepth = ++stackDepth) == 1) {
|
||||
super.start();
|
||||
}
|
||||
clearWhenRestart();
|
||||
|
|
@ -32,7 +40,7 @@ public class EntrySpan extends AbstractTracingSpan {
|
|||
|
||||
@Override
|
||||
public EntrySpan tag(String key, String value) {
|
||||
if (stackDepth == 1) {
|
||||
if (stackDepth == currentMaxDepth) {
|
||||
super.tag(key, value);
|
||||
}
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import org.skywalking.apm.agent.core.dictionary.DictionaryUtil;
|
||||
|
||||
/**
|
||||
* The <code>ExitSpan</code> represents a service consumer point, such as Feign, Okhttp client for a Http service.
|
||||
*
|
||||
|
|
@ -12,12 +14,28 @@ package org.skywalking.apm.agent.core.context.trace;
|
|||
*/
|
||||
public class ExitSpan extends AbstractTracingSpan {
|
||||
private int stackDepth;
|
||||
private String peerPoint;
|
||||
private String peer;
|
||||
private int peerId;
|
||||
|
||||
public ExitSpan(int spanId, int parentSpanId, String operationName, String peerPoint) {
|
||||
public ExitSpan(int spanId, int parentSpanId, String operationName, String peer) {
|
||||
super(spanId, parentSpanId, operationName);
|
||||
this.stackDepth = 0;
|
||||
this.peerPoint = peerPoint;
|
||||
this.peer = peer;
|
||||
this.peerId = DictionaryUtil.nullValue();
|
||||
}
|
||||
|
||||
public ExitSpan(int spanId, int parentSpanId, int operationId, int peerId) {
|
||||
super(spanId, parentSpanId, operationId);
|
||||
this.stackDepth = 0;
|
||||
this.peer = null;
|
||||
this.peerId = peerId;
|
||||
}
|
||||
|
||||
public ExitSpan(int spanId, int parentSpanId, int operationId, String peer) {
|
||||
super(spanId, parentSpanId, operationId);
|
||||
this.stackDepth = 0;
|
||||
this.peer = peer;
|
||||
this.peerId = DictionaryUtil.nullValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -43,7 +61,7 @@ public class ExitSpan extends AbstractTracingSpan {
|
|||
public boolean finish(TraceSegment owner) {
|
||||
if (--stackDepth == 0) {
|
||||
return super.finish(owner);
|
||||
}else{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +74,14 @@ public class ExitSpan extends AbstractTracingSpan {
|
|||
return this;
|
||||
}
|
||||
|
||||
public int getPeerId() {
|
||||
return peerId;
|
||||
}
|
||||
|
||||
public String getPeer() {
|
||||
return peer;
|
||||
}
|
||||
|
||||
@Override public boolean isEntry() {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ package org.skywalking.apm.agent.core.context.trace;
|
|||
*/
|
||||
public class LocalSpan extends AbstractTracingSpan {
|
||||
|
||||
public LocalSpan(int spanId, int parentSpanId, int operationId) {
|
||||
super(spanId, parentSpanId, operationId);
|
||||
}
|
||||
|
||||
public LocalSpan(int spanId, int parentSpanId, String operationName) {
|
||||
super(spanId, parentSpanId, operationName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ public class LogDataEntity {
|
|||
logs = new LinkedList<KeyValuePair>();
|
||||
}
|
||||
|
||||
public Builder add(KeyValuePair... fields){
|
||||
public Builder add(KeyValuePair... fields) {
|
||||
for (KeyValuePair field : fields) {
|
||||
logs.add(field);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LogDataEntity build(){
|
||||
public LogDataEntity build() {
|
||||
return new LogDataEntity(logs);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,19 +8,14 @@ import org.skywalking.apm.agent.core.context.IgnoredTracerContext;
|
|||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class NoopSpan extends AbstractSpan {
|
||||
public class NoopSpan implements AbstractSpan {
|
||||
public NoopSpan() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
super.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSpan log(Throwable t) {
|
||||
return super.log(t);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void finish(){
|
||||
|
|
@ -29,7 +24,7 @@ public class NoopSpan extends AbstractSpan {
|
|||
|
||||
@Override
|
||||
public AbstractSpan tag(String key, String value) {
|
||||
return null;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public boolean isEntry() {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import org.skywalking.apm.agent.core.context.ids.DistributedTraceIds;
|
|||
import org.skywalking.apm.agent.core.context.ids.GlobalIdGenerator;
|
||||
import org.skywalking.apm.agent.core.context.ids.NewDistributedTraceId;
|
||||
import org.skywalking.apm.agent.core.dictionary.DictionaryManager;
|
||||
import org.skywalking.apm.agent.core.dictionary.IDictionaryCompressible;
|
||||
import org.skywalking.apm.agent.core.dictionary.PossibleFound;
|
||||
import org.skywalking.apm.logging.ILog;
|
||||
import org.skywalking.apm.logging.LogManager;
|
||||
|
|
@ -20,9 +19,10 @@ import org.skywalking.apm.logging.LogManager;
|
|||
* TraceSegment} means the segment, which exists in current {@link Thread}. And the distributed trace is formed by multi
|
||||
* {@link TraceSegment}s, because the distributed trace crosses multi-processes, multi-threads.
|
||||
* <p>
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class TraceSegment implements IDictionaryCompressible {
|
||||
public class TraceSegment {
|
||||
private static final ILog logger = LogManager.getLogger(TraceSegment.class);
|
||||
|
||||
private static final String ID_TYPE = "Segment";
|
||||
|
|
@ -89,14 +89,20 @@ public class TraceSegment implements IDictionaryCompressible {
|
|||
* and generate a new segment id.
|
||||
*/
|
||||
public TraceSegment() {
|
||||
DictionaryManager.findApplicationCodeSection()
|
||||
.find(Config.Agent.APPLICATION_CODE, this)
|
||||
.ifFound(new PossibleFound.Setter() {
|
||||
@Override
|
||||
public void set(int value) {
|
||||
applicationId = value;
|
||||
this.applicationId = (Integer)DictionaryManager.findApplicationCodeSection()
|
||||
.find(Config.Agent.APPLICATION_CODE)
|
||||
.doInCondition(
|
||||
new PossibleFound.FoundAndObtain() {
|
||||
@Override public Object doProcess(int applicationId) {
|
||||
return applicationId;
|
||||
}
|
||||
},
|
||||
new PossibleFound.NotFoundAndObtain() {
|
||||
@Override public Object doProcess() {
|
||||
throw new IllegalStateException("Application id must not NULL.");
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
this.startTime = System.currentTimeMillis();
|
||||
this.traceSegmentId = GlobalIdGenerator.generate(ID_TYPE);
|
||||
this.spans = new LinkedList<AbstractTracingSpan>();
|
||||
|
|
@ -164,6 +170,10 @@ public class TraceSegment implements IDictionaryCompressible {
|
|||
return endTime;
|
||||
}
|
||||
|
||||
public int getApplicationId() {
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
public boolean hasRef() {
|
||||
return !(refs == null || refs.size() == 0);
|
||||
}
|
||||
|
|
@ -196,15 +206,4 @@ public class TraceSegment implements IDictionaryCompressible {
|
|||
", relatedGlobalTraces=" + relatedGlobalTraces +
|
||||
'}';
|
||||
}
|
||||
|
||||
/**
|
||||
* If compress is incomplete, this segment will be ignored.
|
||||
*/
|
||||
@Override
|
||||
public void incomplete(String notFoundKey) {
|
||||
if (logger.isDebugEnable()) {
|
||||
logger.debug("Segment[{}] ignored, cause by compress key [{}] not found.", this.traceSegmentId, notFoundKey);
|
||||
}
|
||||
this.ignore = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.ids.DistributedTraceId;
|
||||
|
||||
/**
|
||||
* {@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}.
|
||||
|
|
@ -7,9 +11,6 @@ package org.skywalking.apm.agent.core.context.trace;
|
|||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public class TraceSegmentRef {
|
||||
/**
|
||||
* {@link TraceSegment#traceSegmentId}
|
||||
*/
|
||||
private String traceSegmentId;
|
||||
|
||||
private int spanId = -1;
|
||||
|
|
@ -19,51 +20,16 @@ public class TraceSegmentRef {
|
|||
private String peerHost;
|
||||
|
||||
/**
|
||||
* Create a {@link TraceSegmentRef} instance, without any data.
|
||||
* {@link DistributedTraceId}
|
||||
*/
|
||||
public TraceSegmentRef() {
|
||||
}
|
||||
private List<DistributedTraceId> distributedTraceIds;
|
||||
|
||||
public String getTraceSegmentId() {
|
||||
return traceSegmentId;
|
||||
}
|
||||
|
||||
public void setTraceSegmentId(String traceSegmentId) {
|
||||
this.traceSegmentId = traceSegmentId;
|
||||
}
|
||||
|
||||
public int getSpanId() {
|
||||
return spanId;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TraceSegmentRef{" +
|
||||
"traceSegmentId='" + traceSegmentId + '\'' +
|
||||
", spanId=" + spanId +
|
||||
", applicationCode='" + applicationCode + '\'' +
|
||||
", peerHost='" + peerHost + '\'' +
|
||||
'}';
|
||||
public TraceSegmentRef(ContextCarrier carrier) {
|
||||
this.traceSegmentId = carrier.getTraceSegmentId();
|
||||
this.spanId = carrier.getSpanId();
|
||||
this.applicationCode = carrier.getApplicationCode();
|
||||
this.peerHost = carrier.getPeerHost();
|
||||
this.distributedTraceIds = carrier.getDistributedTraceIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -73,13 +39,17 @@ public class TraceSegmentRef {
|
|||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
TraceSegmentRef that = (TraceSegmentRef) o;
|
||||
TraceSegmentRef ref = (TraceSegmentRef)o;
|
||||
|
||||
return traceSegmentId != null ? traceSegmentId.equals(that.traceSegmentId) : that.traceSegmentId == null;
|
||||
if (spanId != ref.spanId)
|
||||
return false;
|
||||
return traceSegmentId.equals(ref.traceSegmentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return traceSegmentId != null ? traceSegmentId.hashCode() : 0;
|
||||
int result = traceSegmentId.hashCode();
|
||||
result = 31 * result + spanId;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
package org.skywalking.apm.agent.core.dictionary;
|
||||
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Map of application id to application code, which is from the collector side.
|
||||
*
|
||||
|
|
@ -7,8 +12,16 @@ package org.skywalking.apm.agent.core.dictionary;
|
|||
*/
|
||||
public enum ApplicationDictionary {
|
||||
INSTANCE;
|
||||
private Map<String, Integer> applicationDictionary = new ConcurrentHashMap<String, Integer>();
|
||||
private Set<String> unRegisterApplication = new ConcurrentSet<String>();
|
||||
|
||||
public PossibleFound find(String applicationCode, IDictionaryCompressible compressedOwner) {
|
||||
|
||||
public PossibleFound find(String applicationCode) {
|
||||
Integer applicationId = applicationDictionary.get(applicationCode);
|
||||
if (applicationId != null) {
|
||||
return new Found(applicationId);
|
||||
} else {
|
||||
unRegisterApplication.add(applicationCode);
|
||||
return new NotFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,16 @@ package org.skywalking.apm.agent.core.dictionary;
|
|||
*/
|
||||
public class DictionaryManager {
|
||||
/**
|
||||
* @return {@link ApplicationDictionary} to find applicationId
|
||||
* @return {@link ApplicationDictionary} to find application id for application code and network address.
|
||||
*/
|
||||
public static ApplicationDictionary findApplicationCodeSection(){
|
||||
public static ApplicationDictionary findApplicationCodeSection() {
|
||||
return ApplicationDictionary.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link OperationNameDictionary} to find service id.
|
||||
*/
|
||||
public static OperationNameDictionary findOperationNameCodeSection() {
|
||||
return OperationNameDictionary.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package org.skywalking.apm.agent.core.dictionary;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class DictionaryUtil {
|
||||
public static int nullValue() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static boolean isNull(int value) {
|
||||
return value == nullValue();
|
||||
}
|
||||
|
||||
public static boolean isNull(String text) {
|
||||
return text == null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package org.skywalking.apm.agent.core.dictionary;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class DictionaryValueHolder {
|
||||
private int value = DictionaryUtil.nullValue();
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package org.skywalking.apm.agent.core.dictionary;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class Found extends PossibleFound {
|
||||
public Found(int value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package org.skywalking.apm.agent.core.dictionary;
|
||||
|
||||
/**
|
||||
* The <code>IDictionaryCompressible</code> implementation are objects which supported compressing by dictionary.
|
||||
*
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public interface IDictionaryCompressible {
|
||||
/**
|
||||
* The Dictionary notifies, when compress key isn't found,
|
||||
* means compress fail this time.
|
||||
*/
|
||||
void incomplete(String notFoundKey);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package org.skywalking.apm.agent.core.dictionary;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class NotFound extends PossibleFound {
|
||||
public NotFound() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package org.skywalking.apm.agent.core.dictionary;
|
||||
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public enum OperationNameDictionary {
|
||||
INSTANCE;
|
||||
private Map<OperationNameKey, Integer> operationNameDictionary = new ConcurrentHashMap<OperationNameKey, Integer>();
|
||||
private Set<OperationNameKey> unRegisterOperationName = new ConcurrentSet<OperationNameKey>();
|
||||
|
||||
public PossibleFound find(int applicationId, String operationName) {
|
||||
OperationNameKey key = new OperationNameKey(applicationId, operationName);
|
||||
Integer operationId = operationNameDictionary.get(key);
|
||||
if (operationId != null) {
|
||||
return new Found(applicationId);
|
||||
} else {
|
||||
unRegisterOperationName.add(key);
|
||||
return new NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
private class OperationNameKey {
|
||||
private int applicationId;
|
||||
private String operationName;
|
||||
|
||||
public OperationNameKey(int applicationId, String operationName) {
|
||||
this.applicationId = applicationId;
|
||||
this.operationName = operationName;
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
OperationNameKey key = (OperationNameKey)o;
|
||||
|
||||
if (applicationId != key.applicationId)
|
||||
return false;
|
||||
return operationName.equals(key.operationName);
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
int result = applicationId;
|
||||
result = 31 * result + operationName.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ package org.skywalking.apm.agent.core.dictionary;
|
|||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class PossibleFound {
|
||||
public abstract class PossibleFound {
|
||||
private boolean found;
|
||||
private int value;
|
||||
|
||||
|
|
@ -18,13 +18,35 @@ public class PossibleFound {
|
|||
this.found = false;
|
||||
}
|
||||
|
||||
public void ifFound(Setter setter) {
|
||||
public void doInCondition(Found condition1, NotFound condition2) {
|
||||
if (found) {
|
||||
setter.set(value);
|
||||
condition1.doProcess(value);
|
||||
} else {
|
||||
condition2.doProcess();
|
||||
}
|
||||
}
|
||||
|
||||
public interface Setter {
|
||||
void set(int value);
|
||||
public Object doInCondition(FoundAndObtain condition1, NotFoundAndObtain condition2) {
|
||||
if (found) {
|
||||
return condition1.doProcess(value);
|
||||
} else {
|
||||
return condition2.doProcess();
|
||||
}
|
||||
}
|
||||
|
||||
public interface Found {
|
||||
void doProcess(int value);
|
||||
}
|
||||
|
||||
public interface NotFound {
|
||||
void doProcess();
|
||||
}
|
||||
|
||||
public interface FoundAndObtain {
|
||||
Object doProcess(int value);
|
||||
}
|
||||
|
||||
public interface NotFoundAndObtain {
|
||||
Object doProcess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.boot.StatusBootService;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.context.TracingContextListener;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.logging.ILog;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,7 @@ package org.skywalking.apm.agent.core.context.trace;
|
|||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.agent.core.tags.BooleanTagReader;
|
||||
import org.skywalking.apm.agent.core.tags.IntTagReader;
|
||||
import org.skywalking.apm.agent.core.tags.StringTagReader;
|
||||
import org.skywalking.apm.agent.core.context.tag.BooleanTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.IntTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.StringTag;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import java.lang.reflect.Field;
|
|||
import java.util.List;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.agent.core.tags.BooleanTagReader;
|
||||
import org.skywalking.apm.agent.core.tags.StringTagReader;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import org.junit.Test;
|
|||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.ContextManager;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.context.TracingContextListener;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
package org.skywalking.apm.agent.core.tags;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.tag.BooleanTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.BooleanTagItem;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class BooleanTagReader {
|
||||
public static Boolean get(Span span, BooleanTag tag) {
|
||||
List<BooleanTagItem> tagsWithBoolList = null;
|
||||
try {
|
||||
Field tagsWithBool = Span.class.getDeclaredField("tagsWithBool");
|
||||
tagsWithBool.setAccessible(true);
|
||||
tagsWithBoolList = (List<BooleanTagItem>)tagsWithBool.get(span);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (BooleanTagItem item : tagsWithBoolList) {
|
||||
if (tag.key().equals(item.getKey())) {
|
||||
return item.getValue();
|
||||
}
|
||||
}
|
||||
return tag.defaultValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
package org.skywalking.apm.agent.core.tags;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.tag.IntTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.IntTagItem;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class IntTagReader {
|
||||
public static Integer get(Span span, IntTag tag) {
|
||||
List<IntTagItem> tagsWithIntList = null;
|
||||
try {
|
||||
Field tagsWithInt = Span.class.getDeclaredField("tagsWithInt");
|
||||
tagsWithInt.setAccessible(true);
|
||||
tagsWithIntList = (List<IntTagItem>)tagsWithInt.get(span);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (IntTagItem item : tagsWithIntList) {
|
||||
if (tag.key().equals(item.getKey())) {
|
||||
return item.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@ package org.skywalking.apm.agent.core.tags;
|
|||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.tag.StringTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.StringTagItem;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
|||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.ContextCarrier;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import org.mockito.Mock;
|
|||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import org.powermock.api.mockito.PowerMockito;
|
|||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import org.mockito.Matchers;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import org.mockito.Matchers;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import org.mockito.runners.MockitoJUnitRunner;
|
|||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import org.mockito.runners.MockitoJUnitRunner;
|
|||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import org.mockito.Mock;
|
|||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import org.mockito.Mock;
|
|||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import org.mockito.Mock;
|
|||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import org.mockito.Mock;
|
|||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import org.mockito.Mock;
|
|||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.skywalking.apm.sniffer.mock.context;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.agent.core.context.TracingContextListener;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace;
|
||||
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.trace.*;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ package org.skywalking.apm.sniffer.mock.trace.tags;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.tag.BooleanTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.BooleanTagItem;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ package org.skywalking.apm.sniffer.mock.trace.tags;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.tag.IntTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.IntTagItem;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package org.skywalking.apm.sniffer.mock.trace.tags;
|
|||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.tag.StringTag;
|
||||
import org.skywalking.apm.agent.core.context.tag.StringTagItem;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
|
|||
Loading…
Reference in New Issue