use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class KafkaProducerInterceptorTest method testSendMessage.
@Test
public void testSendMessage() throws Throwable {
producerInterceptor.beforeMethod(kafkaProducerInstance, null, arguments, argumentType, null);
producerInterceptor.afterMethod(kafkaProducerInstance, null, arguments, argumentType, null);
List<TraceSegment> traceSegmentList = segmentStorage.getTraceSegments();
assertThat(traceSegmentList.size(), is(1));
TraceSegment segment = traceSegmentList.get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(segment);
assertThat(spans.size(), is(1));
assertMessageSpan(spans.get(0));
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class MotanConsumerInterceptorTest method testResponseWithException.
@Test
public void testResponseWithException() throws Throwable {
when(response.getException()).thenReturn(new RuntimeException());
invokeInterceptor.beforeMethod(enhancedInstance, null, new Object[] { request }, new Class[] { request.getClass() }, null);
invokeInterceptor.afterMethod(enhancedInstance, null, new Object[] { request }, new Class[] { request.getClass() }, response);
MatcherAssert.assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertTraceSegmentWhenOccurException(spans.get(0));
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class MotanConsumerInterceptorTest method testInvokeInterceptor.
@Test
public void testInvokeInterceptor() throws Throwable {
invokeInterceptor.beforeMethod(enhancedInstance, null, new Object[] { request }, new Class[] { request.getClass() }, null);
invokeInterceptor.afterMethod(enhancedInstance, null, new Object[] { request }, new Class[] { request.getClass() }, response);
MatcherAssert.assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertMotanConsumerSpan(spans.get(0));
verify(request, times(1)).setAttachment(anyString(), anyString());
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class SyncHttpRequestSendInterceptorTest method testMethodsAround.
@Test
public void testMethodsAround() throws Throwable {
interceptor.beforeMethod(enhancedInstance, null, allArguments, argumentTypes, null);
interceptor.afterMethod(enhancedInstance, null, allArguments, argumentTypes, null);
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
Assert.assertEquals(1, SegmentHelper.getSpans(traceSegment).size());
AbstractTracingSpan finishedSpan = SegmentHelper.getSpans(traceSegment).get(0);
List<KeyValuePair> tags = SpanHelper.getTags(finishedSpan);
assertThat(tags.size(), is(2));
assertThat(tags.get(0).getValue(), is("GET"));
assertThat(tags.get(1).getValue(), is(uri.toString()));
Assert.assertEquals(false, SpanHelper.getErrorOccurred(finishedSpan));
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class SyncHttpRequestSendInterceptorTest method testMethodsAroundError.
@Test
public void testMethodsAroundError() throws Throwable {
interceptor.beforeMethod(enhancedInstance, null, allArguments, argumentTypes, null);
interceptor.handleMethodException(enhancedInstance, null, allArguments, argumentTypes, new RuntimeException());
interceptor.afterMethod(enhancedInstance, null, allArguments, argumentTypes, null);
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
Assert.assertEquals(1, SegmentHelper.getSpans(traceSegment).size());
AbstractTracingSpan finishedSpan = SegmentHelper.getSpans(traceSegment).get(0);
List<KeyValuePair> tags = SpanHelper.getTags(finishedSpan);
assertThat(tags.size(), is(2));
assertThat(tags.get(0).getValue(), is("GET"));
assertThat(tags.get(1).getValue(), is(uri.toString()));
Assert.assertEquals(true, SpanHelper.getErrorOccurred(finishedSpan));
SpanAssert.assertException(SpanHelper.getLogs(finishedSpan).get(0), RuntimeException.class);
}
Aggregations