use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SkywalkingSpanActivationTest method testCreateExitSpanWithPeer.
@Test
public void testCreateExitSpanWithPeer() throws Throwable {
spanBuilder.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).withTag(Tags.PEER_HOST_IPV4.getKey(), "127.0.0.1").withTag(Tags.PEER_PORT.getKey(), "8080");
startSpan();
stopSpan();
TraceSegment tracingSegment = assertTraceSemgnets();
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(tracingSegment);
assertThat(spans.size(), is(1));
assertSpanCommonsAttribute(spans.get(0));
assertThat(spans.get(0).isEntry(), is(false));
assertThat(spans.get(0).isExit(), is(true));
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SkywalkingSpanActivationTest method testCreateLocalSpan.
@Test
public void testCreateLocalSpan() throws Throwable {
startSpan();
stopSpan();
TraceSegment tracingSegment = assertTraceSemgnets();
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(tracingSegment);
assertThat(spans.size(), is(1));
assertThat(spans.get(0).isEntry(), is(false));
assertThat(spans.get(0).isExit(), is(false));
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class TracingSegmentRunner method withAfters.
@Override
protected Statement withAfters(FrameworkMethod method, Object target, final Statement statement) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
if (field != null) {
try {
tracingData = new SegmentStorage();
field.set(targetObject, tracingData);
} catch (IllegalAccessException e) {
}
}
tracingContextListener = new TracingContextListener() {
@Override
public void afterFinished(TraceSegment traceSegment) {
tracingData.addTraceSegment(traceSegment);
}
};
ignoreTracerContextListener = new IgnoreTracerContextListener() {
@Override
public void afterFinished(IgnoredTracerContext tracerContext) {
tracingData.addIgnoreTraceContext(tracerContext);
}
};
TracingContext.ListenerManager.add(tracingContextListener);
IgnoredTracerContext.ListenerManager.add(ignoreTracerContextListener);
try {
statement.evaluate();
} finally {
TracingContext.ListenerManager.remove(tracingContextListener);
IgnoredTracerContext.ListenerManager.remove(ignoreTracerContextListener);
}
}
};
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class Struts2InterceptorTest method testWithSerializedContextData.
@Test
public void testWithSerializedContextData() throws Throwable {
when(request.getHeader(SW3CarrierItem.HEADER_NAME)).thenReturn("1.234.111|3|1|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*");
struts2Interceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
struts2Interceptor.afterMethod(enhancedInstance, null, arguments, argumentType, null);
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertHttpSpan(spans.get(0));
assertTraceSegmentRef(traceSegment.getRefs().get(0));
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class Struts2InterceptorTest method testWithOccurException.
@Test
public void testWithOccurException() throws Throwable {
struts2Interceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
struts2Interceptor.handleMethodException(enhancedInstance, null, arguments, argumentType, new RuntimeException());
struts2Interceptor.afterMethod(enhancedInstance, null, arguments, argumentType, null);
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertHttpSpan(spans.get(0));
List<LogDataEntity> logDataEntities = SpanHelper.getLogs(spans.get(0));
assertThat(logDataEntities.size(), is(1));
assertException(logDataEntities.get(0), RuntimeException.class);
}
Aggregations