Search in sources :

Example 96 with AbstractTracingSpan

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

the class TransportClientHandlerInterceptorTest method testConsumer.

@Test
public void testConsumer() throws Throwable {
    nextInterceptor.beforeMethod(enhancedInstance, null, allArguments, argumentsType, null);
    nextInterceptor.afterMethod(enhancedInstance, null, 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 97 with AbstractTracingSpan

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

the class InterceptorTest method assertSyncExecute.

@Test
public void assertSyncExecute() throws Throwable {
    executeInterceptor.beforeMethod(null, null, allArguments, null, null);
    sendEvent("ds_0", "select * from t_order_0");
    executeInterceptor.afterMethod(null, null, allArguments, null, null);
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment segment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(segment);
    assertNotNull(spans);
    assertThat(spans.size(), is(2));
    assertSpan(spans.get(0), 0);
    assertThat(spans.get(1).getOperationName(), is("/SJDBC/TRUNK/DQL"));
}
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 98 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 99 with AbstractTracingSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan 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);
}
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 100 with AbstractTracingSpan

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

the class TransportClientHandlerInterceptorTest method testConsumer.

@Test
public void testConsumer() throws Throwable {
    nextInterceptor.beforeMethod(enhancedInstance, null, allArguments, argumentsType, null);
    nextInterceptor.afterMethod(enhancedInstance, null, 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)

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