use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment 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);
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment 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.TraceSegment 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();
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment 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));
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class XMemcachedMethodInterceptorTest method testInterceptWithException.
@Test
public void testInterceptWithException() throws Throwable {
interceptor.beforeMethod(enhancedInstance, getMockSetMethod(), allArgument, argumentType, null);
interceptor.handleMethodException(enhancedInstance, getMockSetMethod(), allArgument, argumentType, new RuntimeException());
interceptor.afterMethod(enhancedInstance, getMockSetMethod(), allArgument, argumentType, null);
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertMemcacheSpan(spans.get(0));
assertLogData(SpanHelper.getLogs(spans.get(0)));
}
Aggregations