Finish almost all codes about TracingContext and three new type spans.
This commit is contained in:
parent
22595c9ebe
commit
48b2164f33
|
|
@ -17,6 +17,8 @@ public interface AbstractTracerContext {
|
|||
|
||||
AbstractSpan createSpan(String operationName, SpanType spanType);
|
||||
|
||||
AbstractSpan createSpan(String operationName, SpanType spanType, Injectable injectable);
|
||||
|
||||
AbstractSpan activeSpan();
|
||||
|
||||
void stopSpan(AbstractSpan span);
|
||||
|
|
|
|||
|
|
@ -1,46 +1,55 @@
|
|||
package org.skywalking.apm.agent.core.context;
|
||||
|
||||
import org.skywalking.apm.agent.core.boot.BootService;
|
||||
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.SpanType;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
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
|
||||
* 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
|
||||
* 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>
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class ContextManager implements TracerContextListener, BootService, IgnoreTracerContextListener {
|
||||
public class ContextManager implements TracingContextListener, BootService, IgnoreTracerContextListener {
|
||||
private static ThreadLocal<AbstractTracerContext> CONTEXT = new ThreadLocal<AbstractTracerContext>();
|
||||
|
||||
private static AbstractTracerContext get() {
|
||||
AbstractTracerContext segment = CONTEXT.get();
|
||||
if (segment == null) {
|
||||
segment = new TracerContext();
|
||||
CONTEXT.set(segment);
|
||||
private static AbstractTracerContext getOrCreate(String operationName, boolean forceSampling) {
|
||||
if (StringUtil.isEmpty(operationName)) {
|
||||
throw new IllegalArgumentException("No operation name");
|
||||
}
|
||||
return segment;
|
||||
AbstractTracerContext context = CONTEXT.get();
|
||||
if (context == null) {
|
||||
int suffixIdx = operationName.lastIndexOf(".");
|
||||
if (suffixIdx > -1 && Config.Agent.IGNORE_SUFFIX.contains(operationName.substring(suffixIdx))) {
|
||||
context = new IgnoredTracerContext();
|
||||
} else {
|
||||
SamplingService samplingService = ServiceManager.INSTANCE.findService(SamplingService.class);
|
||||
if (forceSampling || samplingService.trySampling()) {
|
||||
context = new TracingContext();
|
||||
} else {
|
||||
/**
|
||||
* {@link ContextType#AGGREGATED_TRACING}
|
||||
* TODO
|
||||
*/
|
||||
}
|
||||
}
|
||||
CONTEXT.set(context);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link TracerContext#inject(ContextCarrier)}
|
||||
*/
|
||||
public static void inject(ContextCarrier carrier) {
|
||||
get().inject(carrier);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link TracerContext#extract(ContextCarrier)}
|
||||
*/
|
||||
public static void extract(ContextCarrier carrier) {
|
||||
get().extract(carrier);
|
||||
private static AbstractTracerContext get() {
|
||||
return CONTEXT.get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -55,37 +64,46 @@ public class ContextManager implements TracerContextListener, BootService, Ignor
|
|||
}
|
||||
}
|
||||
|
||||
public static AbstractSpan createSpan(String operationName, ContextCarrier carrier) {
|
||||
if (carrier == null) {
|
||||
throw new IllegalArgumentException("ContextCarrier can't be null.");
|
||||
}
|
||||
SamplingService samplingService = ServiceManager.INSTANCE.findService(SamplingService.class);
|
||||
AbstractTracerContext context;
|
||||
if (carrier.isValid()) {
|
||||
samplingService.forceSampled();
|
||||
context = getOrCreate(operationName, true);
|
||||
context.extract(carrier);
|
||||
} else {
|
||||
context = getOrCreate(operationName, false);
|
||||
}
|
||||
return context.createSpan(operationName, SpanType.ENTRY);
|
||||
}
|
||||
|
||||
public static AbstractSpan createSpan(String operationName) {
|
||||
return get().createSpan(operationName, false);
|
||||
AbstractTracerContext context = getOrCreate(operationName, false);
|
||||
return context.createSpan(operationName, SpanType.LOCAL);
|
||||
}
|
||||
|
||||
public static AbstractSpan createSpan(String operationName, long startTime) {
|
||||
return get().createSpan(operationName, startTime, false);
|
||||
}
|
||||
|
||||
public static AbstractSpan createLeafSpan(String operationName) {
|
||||
return get().createSpan(operationName, true);
|
||||
}
|
||||
|
||||
public static AbstractSpan createLeafSpan(String operationName, long startTime) {
|
||||
return get().createSpan(operationName, startTime, true);
|
||||
public static AbstractSpan createSpan(String operationName, Injectable injectable) {
|
||||
if (injectable == null) {
|
||||
throw new IllegalArgumentException("Injectable can't be null.");
|
||||
}
|
||||
AbstractTracerContext context = getOrCreate(operationName, false);
|
||||
return context.createSpan(operationName, SpanType.EXIT);
|
||||
}
|
||||
|
||||
public static AbstractSpan activeSpan() {
|
||||
return get().activeSpan();
|
||||
}
|
||||
|
||||
public static void stopSpan(Long endTime) {
|
||||
get().stopSpan(activeSpan(), endTime);
|
||||
}
|
||||
|
||||
public static void stopSpan() {
|
||||
get().stopSpan(activeSpan());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bootUp() {
|
||||
TracerContext.ListenerManager.add(this);
|
||||
TracingContext.ListenerManager.add(this);
|
||||
IgnoredTracerContext.ListenerManager.add(this);
|
||||
}
|
||||
|
||||
|
|
@ -98,20 +116,4 @@ public class ContextManager implements TracerContextListener, BootService, Ignor
|
|||
public void afterFinished(IgnoredTracerContext traceSegment) {
|
||||
CONTEXT.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ContextSwitcher</code> gives the chance to switch {@link AbstractTracerContext} in {@link #CONTEXT},
|
||||
* for ignore, sampling, and analytic trace.
|
||||
*/
|
||||
public enum ContextSwitcher {
|
||||
INSTANCE;
|
||||
|
||||
public void toNew(AbstractTracerContext context) {
|
||||
AbstractTracerContext existedContext = CONTEXT.get();
|
||||
if (existedContext != null) {
|
||||
existedContext.dispose();
|
||||
}
|
||||
CONTEXT.set(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ public class IgnoredTracerContext implements AbstractTracerContext {
|
|||
|
||||
private int stackDepth;
|
||||
|
||||
public IgnoredTracerContext(int initStackDepth) {
|
||||
this.stackDepth = initStackDepth;
|
||||
public IgnoredTracerContext() {
|
||||
this.stackDepth = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package org.skywalking.apm.agent.core.context;
|
||||
|
||||
/**
|
||||
* The <code>Injectable</code> represents a callback
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public interface Injectable {
|
||||
/**
|
||||
* @param injectedCarrier notify the <code>Injectable</code> the {@link ContextCarrier} has been injected.
|
||||
*/
|
||||
void notify(ContextCarrier injectedCarrier);
|
||||
|
||||
/**
|
||||
* @return peer, represent ipv4, ipv6, hostname, or cluster addresses list.
|
||||
*/
|
||||
String getPeer();
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ public final class TracerContext implements AbstractTracerContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Finish this context, and notify all {@link TracerContextListener}s, managed by {@link ListenerManager}
|
||||
* Finish this context, and notify all {@link TracingContextListener}s, managed by {@link ListenerManager}
|
||||
*/
|
||||
private void finish() {
|
||||
TraceSegment finishedSegment = segment.finish();
|
||||
|
|
@ -259,34 +259,34 @@ public final class TracerContext implements AbstractTracerContext {
|
|||
}
|
||||
|
||||
public static class ListenerManager {
|
||||
private static List<TracerContextListener> LISTENERS = new LinkedList<TracerContextListener>();
|
||||
private static List<TracingContextListener> LISTENERS = new LinkedList<TracingContextListener>();
|
||||
|
||||
/**
|
||||
* Add the given {@link TracerContextListener} to {@link #LISTENERS} list.
|
||||
* Add the given {@link TracingContextListener} to {@link #LISTENERS} list.
|
||||
*
|
||||
* @param listener the new listener.
|
||||
*/
|
||||
public static synchronized void add(TracerContextListener 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 TracerContextListener#afterFinished(TraceSegment)}
|
||||
* {@link TracingContextListener#afterFinished(TraceSegment)}
|
||||
*
|
||||
* @param finishedSegment
|
||||
*/
|
||||
static void notifyFinish(TraceSegment finishedSegment) {
|
||||
for (TracerContextListener listener : LISTENERS) {
|
||||
for (TracingContextListener listener : LISTENERS) {
|
||||
listener.afterFinished(finishedSegment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the given {@link TracerContextListener}
|
||||
* Clear the given {@link TracingContextListener}
|
||||
*/
|
||||
public static synchronized void remove(TracerContextListener listener) {
|
||||
public static synchronized void remove(TracingContextListener listener) {
|
||||
LISTENERS.remove(listener);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
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.AbstractTracingSpan;
|
||||
import org.skywalking.apm.agent.core.context.trace.EntrySpan;
|
||||
import org.skywalking.apm.agent.core.context.trace.ExitSpan;
|
||||
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.dictionary.DictionaryManager;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
|
||||
import org.skywalking.apm.agent.core.sampling.SamplingService;
|
||||
|
||||
/**
|
||||
|
|
@ -30,7 +33,7 @@ public class TracingContext implements AbstractTracerContext {
|
|||
private int spanIdGenerator;
|
||||
|
||||
TracingContext() {
|
||||
this.segment = new TraceSegment(DictionaryManager.getApplicationDictionary().findId(Config.Agent.APPLICATION_CODE));
|
||||
this.segment = new TraceSegment();
|
||||
this.spanIdGenerator = 0;
|
||||
if (samplingService == null) {
|
||||
samplingService = ServiceManager.INSTANCE.findService(SamplingService.class);
|
||||
|
|
@ -44,7 +47,8 @@ public class TracingContext implements AbstractTracerContext {
|
|||
|
||||
@Override
|
||||
public void extract(ContextCarrier carrier) {
|
||||
|
||||
this.segment.ref(getRef(carrier));
|
||||
this.segment.relatedGlobalTraces(carrier.getDistributedTraceIds());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -54,7 +58,40 @@ public class TracingContext implements AbstractTracerContext {
|
|||
|
||||
@Override
|
||||
public AbstractSpan createSpan(String operationName, SpanType spanType) {
|
||||
return null;
|
||||
return createSpan(operationName, spanType, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSpan createSpan(String operationName, SpanType spanType, Injectable injectable) {
|
||||
AbstractTracingSpan parentSpan = peek();
|
||||
AbstractTracingSpan span = createByType(spanIdGenerator++, -1, operationName,
|
||||
spanType, injectable.getPeer(), parentSpan);
|
||||
return span.start();
|
||||
}
|
||||
|
||||
private AbstractTracingSpan createByType(int spanId, int parentSpanId,
|
||||
String operationName, SpanType spanType,
|
||||
String peerHost, AbstractTracingSpan parentSpan) {
|
||||
switch (spanType) {
|
||||
case LOCAL:
|
||||
return new LocalSpan(spanId, parentSpanId, operationName);
|
||||
case EXIT:
|
||||
if (parentSpan != null && parentSpan.isExit()) {
|
||||
return parentSpan;
|
||||
} else {
|
||||
return new ExitSpan(spanId, parentSpanId, operationName, peerHost);
|
||||
}
|
||||
case ENTRY:
|
||||
if (parentSpan.isEntry()) {
|
||||
return parentSpan;
|
||||
} else if (parentSpan == null) {
|
||||
return new EntrySpan(spanId, parentSpanId, operationName);
|
||||
} else {
|
||||
throw new IllegalStateException("The Entry Span can't be the child of Non-Entry Span");
|
||||
}
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported Span type:" + spanType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -68,7 +105,38 @@ public class TracingContext implements AbstractTracerContext {
|
|||
|
||||
@Override
|
||||
public void stopSpan(AbstractSpan span) {
|
||||
AbstractTracingSpan lastSpan = peek();
|
||||
if (lastSpan == span) {
|
||||
if (lastSpan.finish(segment)) {
|
||||
pop();
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Stopping the unexpected span = " + span);
|
||||
}
|
||||
|
||||
if (activeSpanStack.isEmpty()) {
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish this context, and notify all {@link TracingContextListener}s, managed by {@link
|
||||
* TracerContext.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);
|
||||
}
|
||||
}
|
||||
TracerContext.ListenerManager.notifyFinish(finishedSegment);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -77,6 +145,40 @@ public class TracingContext implements AbstractTracerContext {
|
|||
this.activeSpanStack = null;
|
||||
}
|
||||
|
||||
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 TracerContext.ListenerManager} about the given {@link TraceSegment} have finished.
|
||||
* And trigger {@link TracerContext.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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the top element of 'ActiveSpanStack', and remove it.
|
||||
*/
|
||||
|
|
@ -102,4 +204,13 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ package org.skywalking.apm.agent.core.context;
|
|||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* {@link TracerContextListener} is a status change listener of {@link TracerContext}.
|
||||
* Add a {@link TracerContextListener} implementation through {@link TracerContext}
|
||||
* {@link TracingContextListener} is a status change listener of {@link TracerContext}.
|
||||
* Add a {@link TracingContextListener} implementation through {@link TracerContext}
|
||||
* <p>
|
||||
* All this class's methods will be called concurrently. Make sure all implementations are thread-safe.
|
||||
* <p>
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public interface TracerContextListener {
|
||||
public interface TracingContextListener {
|
||||
/**
|
||||
* This method will be called, after the {@link TracerContext#finish()}
|
||||
*
|
||||
|
|
@ -33,8 +33,9 @@ public abstract class AbstractSpan {
|
|||
this.operationName = operationName;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
public AbstractSpan start() {
|
||||
this.startTime = System.currentTimeMillis();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -36,8 +36,9 @@ public abstract class AbstractTracingSpan extends AbstractSpan {
|
|||
*
|
||||
* @param owner of the Span.
|
||||
*/
|
||||
public void finish(TraceSegment owner) {
|
||||
public boolean finish(TraceSegment owner) {
|
||||
this.endTime = System.currentTimeMillis();
|
||||
owner.archive(this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,11 +22,12 @@ public class EntrySpan extends AbstractTracingSpan {
|
|||
* Set the {@link #startTime}, when the first start, which means the first service provided.
|
||||
*/
|
||||
@Override
|
||||
public void start() {
|
||||
public EntrySpan start() {
|
||||
if (++stackDepth == 1) {
|
||||
super.start();
|
||||
}
|
||||
clearWhenRestart();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -38,9 +39,11 @@ public class EntrySpan extends AbstractTracingSpan {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void finish(TraceSegment owner) {
|
||||
public boolean finish(TraceSegment owner) {
|
||||
if (--stackDepth == 0) {
|
||||
super.finish(owner);
|
||||
return super.finish(owner);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@ public class ExitSpan extends AbstractTracingSpan {
|
|||
* Set the {@link #startTime}, when the first start, which means the first service provided.
|
||||
*/
|
||||
@Override
|
||||
public void start() {
|
||||
public ExitSpan start() {
|
||||
if (++stackDepth == 1) {
|
||||
super.start();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -39,9 +40,11 @@ public class ExitSpan extends AbstractTracingSpan {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void finish(TraceSegment owner) {
|
||||
public boolean finish(TraceSegment owner) {
|
||||
if (--stackDepth == 0) {
|
||||
super.finish(owner);
|
||||
return super.finish(owner);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.context.ids.DistributedTraceId;
|
||||
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;
|
||||
|
||||
/**
|
||||
* {@link TraceSegment} is a segment or fragment of the distributed trace.
|
||||
|
|
@ -17,7 +22,9 @@ import org.skywalking.apm.agent.core.context.ids.NewDistributedTraceId;
|
|||
* <p>
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public class TraceSegment {
|
||||
public class TraceSegment implements IDictionaryCompressible {
|
||||
private static final ILog logger = LogManager.getLogger(TraceSegment.class);
|
||||
|
||||
private static final String ID_TYPE = "Segment";
|
||||
|
||||
/**
|
||||
|
|
@ -76,20 +83,20 @@ public class TraceSegment {
|
|||
|
||||
private boolean ignore = false;
|
||||
|
||||
/**
|
||||
* Create a trace segment, by the given applicationId.
|
||||
*/
|
||||
public TraceSegment(int applicationId) {
|
||||
this();
|
||||
this.applicationId = applicationId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a default/empty trace segment,
|
||||
* with current time as start time,
|
||||
* 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.startTime = System.currentTimeMillis();
|
||||
this.traceSegmentId = GlobalIdGenerator.generate(ID_TYPE);
|
||||
this.spans = new LinkedList<AbstractTracingSpan>();
|
||||
|
|
@ -189,4 +196,15 @@ public class TraceSegment {
|
|||
", 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package org.skywalking.apm.agent.core.dictionary;
|
|||
public enum ApplicationDictionary {
|
||||
INSTANCE;
|
||||
|
||||
public int findId(String applicationCode) {
|
||||
public PossibleFound find(String applicationCode, IDictionaryCompressible compressedOwner) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ public class DictionaryManager {
|
|||
/**
|
||||
* @return {@link ApplicationDictionary} to find applicationId
|
||||
*/
|
||||
public static ApplicationDictionary getApplicationDictionary(){
|
||||
public static ApplicationDictionary findApplicationCodeSection(){
|
||||
return ApplicationDictionary.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
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,30 @@
|
|||
package org.skywalking.apm.agent.core.dictionary;
|
||||
|
||||
/**
|
||||
* The <code>PossibleFound</code> represents a value, which may exist or not.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class PossibleFound {
|
||||
private boolean found;
|
||||
private int value;
|
||||
|
||||
PossibleFound(int value) {
|
||||
this.found = true;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
PossibleFound() {
|
||||
this.found = false;
|
||||
}
|
||||
|
||||
public void ifFound(Setter setter) {
|
||||
if (found) {
|
||||
setter.set(value);
|
||||
}
|
||||
}
|
||||
|
||||
public interface Setter {
|
||||
void set(int value);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ 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.TracerContextListener;
|
||||
import org.skywalking.apm.agent.core.context.TracingContextListener;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.skywalking.apm.logging.ILog;
|
||||
import org.skywalking.apm.logging.LogManager;
|
||||
|
|
@ -22,7 +22,7 @@ import org.skywalking.apm.logging.LogManager;
|
|||
* <p>
|
||||
* Created by wusheng on 2017/2/17.
|
||||
*/
|
||||
public class TraceSegmentProcessQueue extends StatusBootService implements TracerContextListener, EventHandler<TraceSegmentHolder> {
|
||||
public class TraceSegmentProcessQueue extends StatusBootService implements TracingContextListener, EventHandler<TraceSegmentHolder> {
|
||||
private static final ILog logger = LogManager.getLogger(TraceSegmentProcessQueue.class);
|
||||
|
||||
private Disruptor<TraceSegmentHolder> disruptor;
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ public class ContextManagerTestCase {
|
|||
|
||||
Assert.assertEquals(span, ContextManager.activeSpan());
|
||||
|
||||
TracerContext.ListenerManager.add(TestTracerContextListener.INSTANCE);
|
||||
TracerContext.ListenerManager.add(TestTracingContextListener.INSTANCE);
|
||||
ContextManager.stopSpan();
|
||||
|
||||
TraceSegment segment = TestTracerContextListener.INSTANCE.finishedSegmentCarrier[0];
|
||||
TraceSegment segment = TestTracingContextListener.INSTANCE.finishedSegmentCarrier[0];
|
||||
|
||||
Assert.assertEquals(span, segment.getSpans().get(0));
|
||||
}
|
||||
|
|
@ -66,6 +66,6 @@ public class ContextManagerTestCase {
|
|||
|
||||
@After
|
||||
public void reset() {
|
||||
TracerContext.ListenerManager.remove(TestTracerContextListener.INSTANCE);
|
||||
TracerContext.ListenerManager.remove(TestTracingContextListener.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
|||
/**
|
||||
* Created by wusheng on 2017/2/19.
|
||||
*/
|
||||
public enum TestTracerContextListener implements TracerContextListener {
|
||||
public enum TestTracingContextListener implements TracingContextListener {
|
||||
INSTANCE;
|
||||
final TraceSegment[] finishedSegmentCarrier = {null};
|
||||
|
||||
|
|
@ -21,8 +21,8 @@ public class TracerContextTestCase {
|
|||
|
||||
Assert.assertEquals(span, context.activeSpan());
|
||||
|
||||
TracerContext.ListenerManager.add(TestTracerContextListener.INSTANCE);
|
||||
final TraceSegment[] finishedSegmentCarrier = TestTracerContextListener.INSTANCE.finishedSegmentCarrier;
|
||||
TracerContext.ListenerManager.add(TestTracingContextListener.INSTANCE);
|
||||
final TraceSegment[] finishedSegmentCarrier = TestTracingContextListener.INSTANCE.finishedSegmentCarrier;
|
||||
context.stopSpan(span);
|
||||
|
||||
Assert.assertNotNull(finishedSegmentCarrier[0]);
|
||||
|
|
@ -38,8 +38,8 @@ public class TracerContextTestCase {
|
|||
|
||||
Assert.assertEquals(dbSpan, context.activeSpan());
|
||||
|
||||
TracerContext.ListenerManager.add(TestTracerContextListener.INSTANCE);
|
||||
final TraceSegment[] finishedSegmentCarrier = TestTracerContextListener.INSTANCE.finishedSegmentCarrier;
|
||||
TracerContext.ListenerManager.add(TestTracingContextListener.INSTANCE);
|
||||
final TraceSegment[] finishedSegmentCarrier = TestTracingContextListener.INSTANCE.finishedSegmentCarrier;
|
||||
|
||||
try {
|
||||
context.stopSpan(serviceSpan);
|
||||
|
|
@ -87,8 +87,8 @@ public class TracerContextTestCase {
|
|||
context.extract(carrier);
|
||||
AbstractSpan span = context.createSpan("/serviceC", false);
|
||||
|
||||
TracerContext.ListenerManager.add(TestTracerContextListener.INSTANCE);
|
||||
final TraceSegment[] finishedSegmentCarrier = TestTracerContextListener.INSTANCE.finishedSegmentCarrier;
|
||||
TracerContext.ListenerManager.add(TestTracingContextListener.INSTANCE);
|
||||
final TraceSegment[] finishedSegmentCarrier = TestTracingContextListener.INSTANCE.finishedSegmentCarrier;
|
||||
|
||||
context.stopSpan(span);
|
||||
|
||||
|
|
@ -98,6 +98,6 @@ public class TracerContextTestCase {
|
|||
|
||||
@After
|
||||
public void reset() {
|
||||
TracerContext.ListenerManager.remove(TestTracerContextListener.INSTANCE);
|
||||
TracerContext.ListenerManager.remove(TestTracingContextListener.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ 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.TracerContextListener;
|
||||
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;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
|
@ -19,7 +19,7 @@ import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
|||
public class SamplingTracerContextTestCase {
|
||||
private int finishedTracerCounter = 0;
|
||||
|
||||
private TracerContextListener listener = new TracerContextListener() {
|
||||
private TracingContextListener listener = new TracingContextListener() {
|
||||
@Override
|
||||
public void afterFinished(TraceSegment traceSegment) {
|
||||
if (!traceSegment.isIgnore()) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceCon
|
|||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.skywalking.apm.plugin.dubbox.BugFixActive;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
|
|
@ -42,7 +42,7 @@ import static org.powermock.api.mockito.PowerMockito.when;
|
|||
@PrepareForTest({RpcContext.class, BugFixActive.class})
|
||||
public class DubboInterceptorTest {
|
||||
|
||||
private MockTracerContextListener mockTracerContextListener;
|
||||
private MockTracingContextListener mockTracerContextListener;
|
||||
private DubboInterceptor dubboInterceptor;
|
||||
private RequestParamForTestBelow283 testParam;
|
||||
@Mock
|
||||
|
|
@ -66,7 +66,7 @@ public class DubboInterceptorTest {
|
|||
|
||||
dubboInterceptor = new DubboInterceptor();
|
||||
testParam = new RequestParamForTestBelow283();
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
mockTracerContextListener = new MockTracingContextListener();
|
||||
TracerContext.ListenerManager.add(mockTracerContextListener);
|
||||
|
||||
mockStatic(RpcContext.class);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ 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.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.BooleanTagReader;
|
||||
|
|
@ -36,7 +36,7 @@ import static org.mockito.Mockito.when;
|
|||
public class DefaultHttpClientInterceptorTest {
|
||||
|
||||
private DefaultHttpClientInterceptor defaultHttpClientInterceptor;
|
||||
private MockTracerContextListener mockTracerContextListener;
|
||||
private MockTracingContextListener mockTracerContextListener;
|
||||
|
||||
private EnhancedClassInstanceContext classInstanceContext;
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ public class DefaultHttpClientInterceptorTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
mockTracerContextListener = new MockTracingContextListener();
|
||||
|
||||
classInstanceContext = new EnhancedClassInstanceContext();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ 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.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.BooleanTagReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
|
|
@ -33,7 +33,7 @@ import static org.mockito.Mockito.*;
|
|||
public class HttpClientExecuteInterceptorTest {
|
||||
|
||||
private HttpClientExecuteInterceptor httpClientExecuteInterceptor;
|
||||
private MockTracerContextListener mockTracerContextListener;
|
||||
private MockTracingContextListener mockTracerContextListener;
|
||||
@Mock
|
||||
private EnhancedClassInstanceContext classInstanceContext;
|
||||
@Mock
|
||||
|
|
@ -49,7 +49,7 @@ public class HttpClientExecuteInterceptorTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
mockTracerContextListener = new MockTracingContextListener();
|
||||
|
||||
ServiceManager.INSTANCE.boot();
|
||||
httpClientExecuteInterceptor = new HttpClientExecuteInterceptor();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.skywalking.apm.plugin.jdbc;
|
|||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.agent.core.context.tag.Tags;
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ import static org.junit.Assert.*;
|
|||
|
||||
public abstract class AbstractStatementTest {
|
||||
|
||||
protected MockTracerContextListener mockTracerContextListener;
|
||||
protected MockTracingContextListener mockTracerContextListener;
|
||||
|
||||
protected void assertDBSpanLog(LogData logData) {
|
||||
assertThat(logData.getFields().size(), is(4));
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ 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.MockTracerContextListener;
|
||||
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;
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ public class SWCallableStatementTest extends AbstractStatementTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
mockTracerContextListener = new MockTracingContextListener();
|
||||
ServiceManager.INSTANCE.boot();
|
||||
swConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306/test", new Properties(), jdbcConnection);
|
||||
multiHostConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306,127.0.0.1:3309/test", new Properties(), jdbcConnection);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ 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.MockTracerContextListener;
|
||||
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;
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ public class SWConnectionTest extends AbstractStatementTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ServiceManager.INSTANCE.boot();
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
mockTracerContextListener = new MockTracingContextListener();
|
||||
swConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306/test", new Properties(), jdbcConnection);
|
||||
multiHostConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306,127.0.0.1:3309/test", new Properties(), jdbcConnection);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ 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.MockTracerContextListener;
|
||||
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;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public class SWStatementTest extends AbstractStatementTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
mockTracerContextListener = new MockTracingContextListener();
|
||||
|
||||
ServiceManager.INSTANCE.boot();
|
||||
swConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306/test", new Properties(), jdbcConnection);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ 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.MockTracerContextListener;
|
||||
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;
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ public class SwPreparedStatementTest extends AbstractStatementTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
mockTracerContextListener = new MockTracingContextListener();
|
||||
|
||||
ServiceManager.INSTANCE.boot();
|
||||
swConnection = new SWConnection("jdbc:mysql://127.0.0.1:3306/test", new Properties(), jdbcConnection);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ 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.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
|
@ -30,7 +30,7 @@ public class JedisMethodInterceptorTest {
|
|||
|
||||
private JedisMethodInterceptor interceptor;
|
||||
|
||||
private MockTracerContextListener mockTracerContextListener;
|
||||
private MockTracingContextListener mockTracerContextListener;
|
||||
|
||||
@Mock
|
||||
private EnhancedClassInstanceContext classInstanceContext;
|
||||
|
|
@ -42,7 +42,7 @@ public class JedisMethodInterceptorTest {
|
|||
ServiceManager.INSTANCE.boot();
|
||||
|
||||
interceptor = new JedisMethodInterceptor();
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
mockTracerContextListener = new MockTracingContextListener();
|
||||
|
||||
TracerContext.ListenerManager.add(mockTracerContextListener);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ 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.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
|
|
@ -34,7 +34,7 @@ import static org.mockito.Mockito.when;
|
|||
public class MongoDBMethodInterceptorTest {
|
||||
|
||||
private MongoDBMethodInterceptor interceptor;
|
||||
private MockTracerContextListener mockTracerContextListener;
|
||||
private MockTracingContextListener mockTracerContextListener;
|
||||
|
||||
@Mock
|
||||
private EnhancedClassInstanceContext classInstanceContext;
|
||||
|
|
@ -47,7 +47,7 @@ public class MongoDBMethodInterceptorTest {
|
|||
ServiceManager.INSTANCE.boot();
|
||||
|
||||
interceptor = new MongoDBMethodInterceptor();
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
mockTracerContextListener = new MockTracingContextListener();
|
||||
|
||||
TracerContext.ListenerManager.add(mockTracerContextListener);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ 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.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
|
|
@ -38,7 +38,7 @@ import static org.mockito.Mockito.when;
|
|||
public class MongoDBWriteMethodInterceptorTest {
|
||||
|
||||
private MongoDBMethodInterceptor interceptor;
|
||||
private MockTracerContextListener mockTracerContextListener;
|
||||
private MockTracingContextListener mockTracerContextListener;
|
||||
|
||||
@Mock
|
||||
private EnhancedClassInstanceContext classInstanceContext;
|
||||
|
|
@ -50,7 +50,7 @@ public class MongoDBWriteMethodInterceptorTest {
|
|||
ServiceManager.INSTANCE.boot();
|
||||
|
||||
interceptor = new MongoDBMethodInterceptor();
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
mockTracerContextListener = new MockTracingContextListener();
|
||||
|
||||
TracerContext.ListenerManager.add(mockTracerContextListener);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ 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.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
|
|
@ -30,7 +30,7 @@ import static org.mockito.Mockito.*;
|
|||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MotanConsumerInterceptorTest {
|
||||
|
||||
private MockTracerContextListener contextListener;
|
||||
private MockTracingContextListener contextListener;
|
||||
|
||||
private MotanConsumerInterceptor invokeInterceptor;
|
||||
@Mock
|
||||
|
|
@ -48,7 +48,7 @@ public class MotanConsumerInterceptorTest {
|
|||
public void setUp() {
|
||||
ServiceManager.INSTANCE.boot();
|
||||
|
||||
contextListener = new MockTracerContextListener();
|
||||
contextListener = new MockTracingContextListener();
|
||||
invokeInterceptor = new MotanConsumerInterceptor();
|
||||
url = URL.valueOf("motan://127.0.0.1:34000/org.skywalking.apm.test.TestService");
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ 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;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader;
|
||||
|
|
@ -34,7 +34,7 @@ import static org.mockito.Mockito.when;
|
|||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MotanProviderInterceptorTest {
|
||||
|
||||
private MockTracerContextListener contextListener;
|
||||
private MockTracingContextListener contextListener;
|
||||
|
||||
private MotanProviderInterceptor invokeInterceptor;
|
||||
@Mock
|
||||
|
|
@ -55,7 +55,7 @@ public class MotanProviderInterceptorTest {
|
|||
ServiceManager.INSTANCE.boot();
|
||||
|
||||
invokeInterceptor = new MotanProviderInterceptor();
|
||||
contextListener = new MockTracerContextListener();
|
||||
contextListener = new MockTracingContextListener();
|
||||
url = URL.valueOf("motan://127.0.0.1:34000/org.skywalking.apm.test.TestService");
|
||||
|
||||
TracerContext.ListenerManager.add(contextListener);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ 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;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.BooleanTagReader;
|
||||
|
|
@ -34,7 +34,7 @@ import static org.mockito.Mockito.when;
|
|||
public class RealCallInterceptorTest {
|
||||
|
||||
private RealCallInterceptor realCallInterceptor;
|
||||
private MockTracerContextListener mockTracerContextListener;
|
||||
private MockTracingContextListener mockTracerContextListener;
|
||||
|
||||
private EnhancedClassInstanceContext classInstanceContext;
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ public class RealCallInterceptorTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockTracerContextListener = new MockTracerContextListener();
|
||||
mockTracerContextListener = new MockTracingContextListener();
|
||||
|
||||
classInstanceContext = new EnhancedClassInstanceContext();
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ 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;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.IntTagReader;
|
||||
|
|
@ -38,7 +38,7 @@ import static org.mockito.Mockito.when;
|
|||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ResinV3InterceptorTest {
|
||||
private ResinV3Interceptor interceptor;
|
||||
private MockTracerContextListener contextListener;
|
||||
private MockTracingContextListener contextListener;
|
||||
|
||||
@Mock
|
||||
private CauchoRequest request;
|
||||
|
|
@ -57,7 +57,7 @@ public class ResinV3InterceptorTest {
|
|||
ServiceManager.INSTANCE.boot();
|
||||
|
||||
interceptor = new ResinV3Interceptor();
|
||||
contextListener = new MockTracerContextListener();
|
||||
contextListener = new MockTracingContextListener();
|
||||
|
||||
TracerContext.ListenerManager.add(contextListener);
|
||||
|
||||
|
|
@ -147,6 +147,6 @@ public class ResinV3InterceptorTest {
|
|||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
TracerContext.ListenerManager.remove(new MockTracerContextListener());
|
||||
TracerContext.ListenerManager.remove(new MockTracingContextListener());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ 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;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.IntTagReader;
|
||||
|
|
@ -36,7 +36,7 @@ import static org.mockito.Mockito.when;
|
|||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ResinV4InterceptorTest {
|
||||
private ResinV4Interceptor interceptor;
|
||||
private MockTracerContextListener contextListener;
|
||||
private MockTracingContextListener contextListener;
|
||||
|
||||
@Mock
|
||||
private CauchoRequest request;
|
||||
|
|
@ -55,7 +55,7 @@ public class ResinV4InterceptorTest {
|
|||
ServiceManager.INSTANCE.boot();
|
||||
|
||||
interceptor = new ResinV4Interceptor();
|
||||
contextListener = new MockTracerContextListener();
|
||||
contextListener = new MockTracingContextListener();
|
||||
|
||||
TracerContext.ListenerManager.add(contextListener);
|
||||
|
||||
|
|
@ -146,6 +146,6 @@ public class ResinV4InterceptorTest {
|
|||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
TracerContext.ListenerManager.remove(new MockTracerContextListener());
|
||||
TracerContext.ListenerManager.remove(new MockTracingContextListener());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ 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;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.SpanLogReader;
|
||||
import org.skywalking.apm.sniffer.mock.trace.tags.IntTagReader;
|
||||
|
|
@ -33,7 +33,7 @@ import static org.mockito.Mockito.when;
|
|||
public class TomcatInterceptorTest {
|
||||
|
||||
private TomcatInterceptor tomcatInterceptor;
|
||||
private MockTracerContextListener contextListener;
|
||||
private MockTracingContextListener contextListener;
|
||||
|
||||
@Mock
|
||||
private HttpServletRequest request;
|
||||
|
|
@ -52,7 +52,7 @@ public class TomcatInterceptorTest {
|
|||
ServiceManager.INSTANCE.boot();
|
||||
|
||||
tomcatInterceptor = new TomcatInterceptor();
|
||||
contextListener = new MockTracerContextListener();
|
||||
contextListener = new MockTracingContextListener();
|
||||
|
||||
TracerContext.ListenerManager.add(contextListener);
|
||||
|
||||
|
|
@ -139,6 +139,6 @@ public class TomcatInterceptorTest {
|
|||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
TracerContext.ListenerManager.remove(new MockTracerContextListener());
|
||||
TracerContext.ListenerManager.remove(new MockTracingContextListener());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ 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.TracerContextListener;
|
||||
import org.skywalking.apm.agent.core.context.TracingContextListener;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -10,12 +10,12 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is mock tracer context listener, which should be added by calling {@link TracerContext.ListenerManager#add(TracerContextListener)}.
|
||||
* This is mock tracer context listener, which should be added by calling {@link TracerContext.ListenerManager#add(TracingContextListener)}.
|
||||
* This mock listener will hold all finished trace, which all are generated by {@link TracerContext#finish()}.
|
||||
* <p>
|
||||
* Created by wusheng on 2017/2/20.
|
||||
*/
|
||||
public class MockTracerContextListener implements TracerContextListener {
|
||||
public class MockTracingContextListener implements TracingContextListener {
|
||||
private List<TraceSegment> finishedTraceSegments = Collections.synchronizedList(new ArrayList<TraceSegment>());
|
||||
|
||||
@Override
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace;
|
||||
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/20.
|
||||
*/
|
||||
public interface TraceSegmentBuilder {
|
||||
TraceSegment build(MockTracerContextListener listener);
|
||||
TraceSegment build(MockTracingContextListener listener);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace;
|
||||
|
||||
import org.skywalking.apm.agent.core.context.TracerContext;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
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;
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ public enum TraceSegmentBuilderFactory {
|
|||
}
|
||||
|
||||
private TraceSegment build(TraceSegmentBuilder builder) {
|
||||
MockTracerContextListener listener = new MockTracerContextListener();
|
||||
MockTracingContextListener listener = new MockTracingContextListener();
|
||||
try {
|
||||
TracerContext.ListenerManager.add(listener);
|
||||
return builder.build(listener);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace.builders.trace;
|
||||
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.TraceSegmentBuilder;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.DubboSpanGenerator;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.MySQLGenerator;
|
||||
|
|
@ -13,7 +13,7 @@ public enum DubboServerMysqlTraceBuilder implements TraceSegmentBuilder {
|
|||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public TraceSegment build(MockTracerContextListener listener) {
|
||||
public TraceSegment build(MockTracingContextListener listener) {
|
||||
DubboSpanGenerator.Server rootSpan = new DubboSpanGenerator.Server();
|
||||
rootSpan.build(new MySQLGenerator.Query());
|
||||
rootSpan.generate();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace.builders.trace;
|
||||
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.TraceSegmentBuilder;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.TomcatSpanGenerator;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
|
@ -14,7 +14,7 @@ public enum SingleTomcat200TraceBuilder implements TraceSegmentBuilder {
|
|||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public TraceSegment build(MockTracerContextListener listener) {
|
||||
public TraceSegment build(MockTracingContextListener listener) {
|
||||
TomcatSpanGenerator.ON200.INSTANCE.generate();
|
||||
return listener.getFinished(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace.builders.trace;
|
||||
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.TraceSegmentBuilder;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.TomcatSpanGenerator;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
|
@ -14,7 +14,7 @@ public enum SingleTomcat404TraceBuilder implements TraceSegmentBuilder {
|
|||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public TraceSegment build(MockTracerContextListener listener) {
|
||||
public TraceSegment build(MockTracingContextListener listener) {
|
||||
TomcatSpanGenerator.ON404.INSTANCE.generate();
|
||||
return listener.getFinished(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace.builders.trace;
|
||||
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.TraceSegmentBuilder;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.TomcatSpanGenerator;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
|
@ -14,7 +14,7 @@ public enum SingleTomcat500TraceBuilder implements TraceSegmentBuilder {
|
|||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public TraceSegment build(MockTracerContextListener listener) {
|
||||
public TraceSegment build(MockTracingContextListener listener) {
|
||||
TomcatSpanGenerator.ON500.INSTANCE.generate();
|
||||
return listener.getFinished(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package org.skywalking.apm.sniffer.mock.trace.builders.trace;
|
||||
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.trace.TraceSegmentBuilder;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.DubboSpanGenerator;
|
||||
import org.skywalking.apm.sniffer.mock.trace.builders.span.TomcatSpanGenerator;
|
||||
|
|
@ -17,7 +17,7 @@ public enum TomcatDubboClientTraceBuilder implements TraceSegmentBuilder {
|
|||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public TraceSegment build(MockTracerContextListener listener) {
|
||||
public TraceSegment build(MockTracingContextListener listener) {
|
||||
TomcatSpanGenerator.ON200 rootSpan = new TomcatSpanGenerator.ON200();
|
||||
rootSpan.build(new DubboSpanGenerator.Client());
|
||||
rootSpan.generate();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import org.junit.Assert;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracerContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.MockTracingContextListener;
|
||||
import org.skywalking.apm.sniffer.mock.context.SegmentAssert;
|
||||
import org.skywalking.apm.sniffer.mock.trace.TraceSegmentBuilderFactory;
|
||||
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
|
|
@ -12,7 +12,7 @@ import org.skywalking.apm.agent.core.context.trace.TraceSegment;
|
|||
/**
|
||||
* Created by wusheng on 2017/2/21.
|
||||
*/
|
||||
public class MockTracerContextListenerTestCase {
|
||||
public class MockTracingContextListenerTestCase {
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
ServiceManager.INSTANCE.boot();
|
||||
|
|
@ -20,7 +20,7 @@ public class MockTracerContextListenerTestCase {
|
|||
|
||||
@Test
|
||||
public void testAfterFinished() {
|
||||
MockTracerContextListener listener = new MockTracerContextListener();
|
||||
MockTracingContextListener listener = new MockTracingContextListener();
|
||||
listener.afterFinished(TraceSegmentBuilderFactory.INSTANCE.singleTomcat200Trace());
|
||||
|
||||
Assert.assertNotNull(listener.getFinished(0));
|
||||
|
|
@ -28,7 +28,7 @@ public class MockTracerContextListenerTestCase {
|
|||
|
||||
@Test(expected = AssertionError.class)
|
||||
public void testAssertSize() {
|
||||
MockTracerContextListener listener = new MockTracerContextListener();
|
||||
MockTracingContextListener listener = new MockTracingContextListener();
|
||||
listener.afterFinished(TraceSegmentBuilderFactory.INSTANCE.singleTomcat404Trace());
|
||||
|
||||
listener.assertSize(0);
|
||||
|
|
@ -36,7 +36,7 @@ public class MockTracerContextListenerTestCase {
|
|||
|
||||
@Test
|
||||
public void testAssertTraceSegment() {
|
||||
MockTracerContextListener listener = new MockTracerContextListener();
|
||||
MockTracingContextListener listener = new MockTracingContextListener();
|
||||
listener.afterFinished(TraceSegmentBuilderFactory.INSTANCE.singleTomcat404Trace());
|
||||
listener.afterFinished(TraceSegmentBuilderFactory.INSTANCE.singleTomcat500Trace());
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ public class MockTracerContextListenerTestCase {
|
|||
|
||||
@Test(expected = AssertionError.class)
|
||||
public void testClear() {
|
||||
MockTracerContextListener listener = new MockTracerContextListener();
|
||||
MockTracingContextListener listener = new MockTracingContextListener();
|
||||
listener.afterFinished(TraceSegmentBuilderFactory.INSTANCE.singleTomcat404Trace());
|
||||
listener.afterFinished(TraceSegmentBuilderFactory.INSTANCE.singleTomcat500Trace());
|
||||
|
||||
Loading…
Reference in New Issue