use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class RealCallInterceptorTest method testException.
@Test
public void testException() throws Throwable {
realCallInterceptor.onConstruct(enhancedInstance, allArguments);
realCallInterceptor.beforeMethod(enhancedInstance, null, allArguments, argumentTypes, null);
realCallInterceptor.handleMethodException(enhancedInstance, null, allArguments, argumentTypes, new NullPointerException("testException"));
Response response = mock(Response.class);
when(response.code()).thenReturn(200);
realCallInterceptor.afterMethod(enhancedInstance, null, allArguments, argumentTypes, response);
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertSpan(spans.get(0));
SpanAssert.assertOccurException(spans.get(0), true);
SpanAssert.assertLogSize(spans.get(0), 1);
SpanAssert.assertException(SpanHelper.getLogs(spans.get(0)).get(0), NullPointerException.class, "testException");
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class RealCallInterceptorTest method testMethodsAroundError.
@Test
public void testMethodsAroundError() throws Throwable {
realCallInterceptor.onConstruct(enhancedInstance, allArguments);
realCallInterceptor.beforeMethod(enhancedInstance, null, allArguments, argumentTypes, null);
Response response = mock(Response.class);
when(response.code()).thenReturn(404);
realCallInterceptor.afterMethod(enhancedInstance, null, allArguments, argumentTypes, response);
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertSpan(spans.get(0));
SpanAssert.assertOccurException(spans.get(0), true);
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class ResinV3InterceptorTest method testWithSerializedContextData.
@Test
public void testWithSerializedContextData() throws Throwable {
when(request.getHeader(SW3CarrierItem.HEADER_NAME)).thenReturn("1.333.2345|3|1|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*");
interceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
interceptor.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 ResinV3InterceptorTest method testWithOccurException.
@Test
public void testWithOccurException() throws Throwable {
interceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
interceptor.handleMethodException(enhancedInstance, null, arguments, argumentType, new RuntimeException());
interceptor.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);
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class OnSuccessInterceptorTest method testOnSuccessWithErrorStatus.
@Test
public void testOnSuccessWithErrorStatus() throws Throwable {
when(sendResult.getSendStatus()).thenReturn(SendStatus.FLUSH_SLAVE_TIMEOUT);
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);
SpanAssert.assertOccurException(successSpan, true);
}
Aggregations