Search in sources :

Example 81 with AbstractTracingSpan

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

the class TomcatInvokeInterceptorTest method testWithOccurException.

@Test
public void testWithOccurException() throws Throwable {
    tomcatInvokeInterceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
    tomcatInvokeInterceptor.handleMethodException(enhancedInstance, null, arguments, argumentType, new RuntimeException());
    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 82 with AbstractTracingSpan

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

the class OnSuccessInterceptorTest method testOnSuccess.

@Test
public void testOnSuccess() throws Throwable {
    successInterceptor.beforeMethod(enhancedInstance, null, new Object[] { sendResult }, null, null);
    successInterceptor.afterMethod(enhancedInstance, null, new Object[] { sendResult }, null, null);
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    AbstractTracingSpan successSpan = spans.get(0);
    SpanAssert.assertComponent(successSpan, ComponentsDefine.ROCKET_MQ);
}
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 83 with AbstractTracingSpan

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

the class OnExceptionInterceptorTest method testOnException.

@Test
public void testOnException() throws Throwable {
    exceptionInterceptor.beforeMethod(enhancedInstance, null, new Object[] { new RuntimeException() }, null, null);
    exceptionInterceptor.afterMethod(enhancedInstance, null, new Object[] { new RuntimeException() }, null, null);
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    AbstractTracingSpan exceptionSpan = spans.get(0);
    SpanAssert.assertException(SpanHelper.getLogs(exceptionSpan).get(0), RuntimeException.class);
    SpanAssert.assertOccurException(exceptionSpan, true);
}
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 84 with AbstractTracingSpan

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

the class ProducerOperationHandlerInterceptorTest method testConsumer.

@Test
public void testConsumer() throws Throwable {
    invocationInterceptor.beforeMethod(enhancedInstance, method, allArguments, argumentsType, null);
    invocationInterceptor.afterMethod(enhancedInstance, method, allArguments, argumentsType, null);
    Assert.assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertCombSpan(spans.get(0));
    verify(invocation, times(1)).getContext();
}
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 85 with AbstractTracingSpan

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

the class MemcachedMethodInterceptorTest method testIntercept.

@Test
public void testIntercept() throws Throwable {
    interceptor.beforeMethod(enhancedInstance, getMockSetMethod(), allArgument, argumentType, null);
    interceptor.afterMethod(enhancedInstance, getMockGetMethod(), allArgument, argumentType, null);
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    assertMemcacheSpan(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