Search in sources :

Example 76 with AbstractTracingSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan 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);
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) LogDataEntity(org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 77 with AbstractTracingSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.

the class Struts2InterceptorTest method testWithoutSerializedContextData.

@Test
public void testWithoutSerializedContextData() throws Throwable {
    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));
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 78 with AbstractTracingSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.

the class TomcatInvokeInterceptorTest 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*");
    tomcatInvokeInterceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
    tomcatInvokeInterceptor.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));
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Example 79 with AbstractTracingSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.

the class TomcatInvokeInterceptorTest method testWithTomcatException.

@Test
public void testWithTomcatException() throws Throwable {
    tomcatInvokeInterceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
    tomcatExceptionInterceptor.beforeMethod(enhancedInstance, null, exceptionArguments, exceptionArgumentType, null);
    tomcatInvokeInterceptor.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));
    SpanAssert.assertException(logDataEntities.get(0), RuntimeException.class);
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) LogDataEntity(org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Example 80 with AbstractTracingSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.

the class TomcatInvokeInterceptorTest method testWithoutSerializedContextData.

@Test
public void testWithoutSerializedContextData() throws Throwable {
    tomcatInvokeInterceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
    tomcatInvokeInterceptor.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));
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Aggregations

AbstractTracingSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan)151 TraceSegment (org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)149 Test (org.junit.Test)144 PreparedStatement (java.sql.PreparedStatement)19 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)18 LogDataEntity (org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity)15 SegmentStoragePoint (org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint)14 CallableStatement (java.sql.CallableStatement)13 Method (java.lang.reflect.Method)11 Statement (java.sql.Statement)11 SQLException (java.sql.SQLException)10 KeyValuePair (org.apache.skywalking.apm.agent.core.context.util.KeyValuePair)10 ResultSet (java.sql.ResultSet)7 AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)7 ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)7 Response (feign.Response)3 HashMap (java.util.HashMap)3 Response (okhttp3.Response)3 TraceSegmentRef (org.apache.skywalking.apm.agent.core.context.trace.TraceSegmentRef)3 TextMap (io.opentracing.propagation.TextMap)2