use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class MessageSendInterceptorTest method testSendMessage.
@Test
public void testSendMessage() throws Throwable {
messageSendInterceptor.beforeMethod(enhancedInstance, null, arguments, null, null);
messageSendInterceptor.afterMethod(enhancedInstance, null, arguments, 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 mqSpan = spans.get(0);
SpanAssert.assertLayer(mqSpan, SpanLayer.MQ);
SpanAssert.assertComponent(mqSpan, ComponentsDefine.ROCKET_MQ);
SpanAssert.assertTag(mqSpan, 0, "127.0.0.1");
verify(messageRequestHeader, times(1)).setProperties(anyString());
verify(callBack, times(1)).setSkyWalkingDynamicField(Matchers.any());
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class MessageSendInterceptorTest method testSendMessageWithoutCallBack.
@Test
public void testSendMessageWithoutCallBack() throws Throwable {
messageSendInterceptor.beforeMethod(enhancedInstance, null, argumentsWithoutCallback, null, null);
messageSendInterceptor.afterMethod(enhancedInstance, null, argumentsWithoutCallback, 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 mqSpan = spans.get(0);
SpanAssert.assertLayer(mqSpan, SpanLayer.MQ);
SpanAssert.assertComponent(mqSpan, ComponentsDefine.ROCKET_MQ);
SpanAssert.assertTag(mqSpan, 0, "127.0.0.1");
verify(messageRequestHeader, times(1)).setProperties(anyString());
}
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);
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan 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.AbstractTracingSpan 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);
}
Aggregations