use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWConnectionTest method testMultiHostCommit.
@Test
public void testMultiHostCommit() throws SQLException {
PreparedStatement preparedStatement = swConnection.prepareStatement("SELECT * FROM test", new String[] { "1" });
multiHostConnection.commit();
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");
}
use of org.apache.skywalking.apm.agent.core.context.trace.TraceSegment in project incubator-skywalking by apache.
the class SWConnectionTest method testMultiHostRollBackWithSavePoint.
@Test
public void testMultiHostRollBackWithSavePoint() throws SQLException {
multiHostConnection.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.TraceSegment 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.TraceSegment 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.TraceSegment 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)"));
}
Aggregations