use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class SWConnectionTest method testCommitWithException.
@Test(expected = SQLException.class)
public void testCommitWithException() throws SQLException {
PreparedStatement preparedStatement = swConnection.prepareStatement("SELECT * FROM test", new int[] { 1 });
doThrow(new SQLException()).when(jdbcConnection).commit();
try {
swConnection.commit();
} finally {
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/Connection/commit");
assertThat(SpanHelper.getLogs(spans.get(0)).size(), is(1));
assertDBSpanLog(SpanHelper.getLogs(spans.get(0)).get(0));
}
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class SWConnectionTest method testRollBackWithSavePoint.
@Test
public void testRollBackWithSavePoint() throws SQLException {
swConnection.rollback(savepoint);
assertThat(segmentStorage.getTraceSegments().size(), is(1));
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
assertDBSpan(spans.get(0), "Mysql/JDBI/Connection/rollback to savepoint");
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class JobExecutorInterceptorTest method assertSuccess.
@Test
public void assertSuccess() throws Throwable {
jobExecutorInterceptor.beforeMethod(null, null, new Object[] { mockShardingContext("fooJob", 1), 1 }, null, null);
jobExecutorInterceptor.afterMethod(null, null, null, null, null);
TraceSegment segment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(segment);
assertNotNull(spans);
assertThat(spans.size(), is(1));
assertThat(spans.get(0).transform().getOperationName(), is("fooJob-test"));
assertThat(spans.get(0).transform().getComponentId(), is(24));
assertThat(spans.get(0).transform().getTags(0).getKey(), is("sharding_context"));
assertThat(spans.get(0).transform().getTags(0).getValue(), is("ShardingContext(jobName=fooJob, taskId=fooJob1, shardingTotalCount=2, jobParameter=, shardingItem=1, shardingParameter=test)"));
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class JobExecutorInterceptorTest method assertSuccessWithoutSharding.
@Test
public void assertSuccessWithoutSharding() throws Throwable {
jobExecutorInterceptor.beforeMethod(null, null, new Object[] { mockShardingContext("fooJob", 0), 0 }, null, null);
jobExecutorInterceptor.afterMethod(null, null, null, null, null);
TraceSegment segment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(segment);
assertNotNull(spans);
assertThat(spans.size(), is(1));
assertThat(spans.get(0).transform().getOperationName(), is("fooJob"));
assertThat(spans.get(0).transform().getTags(0).getValue(), is("ShardingContext(jobName=fooJob, taskId=fooJob0, shardingTotalCount=1, jobParameter=, shardingItem=0, shardingParameter=null)"));
}
use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.
the class JobExecutorInterceptorTest method assertError.
@Test
public void assertError() throws Throwable {
jobExecutorInterceptor.beforeMethod(null, null, new Object[] { mockShardingContext("fooJob", 0), 0 }, null, null);
jobExecutorInterceptor.handleMethodException(null, null, null, null, new Exception("fooError"));
jobExecutorInterceptor.afterMethod(null, null, null, null, null);
TraceSegment segment = segmentStorage.getTraceSegments().get(0);
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(segment);
assertNotNull(spans);
assertThat(spans.size(), is(1));
assertThat(spans.get(0).transform().getIsError(), is(true));
assertThat(spans.get(0).transform().getLogs(0).getDataList().size(), is(4));
}
Aggregations