Search in sources :

Example 26 with TraceSegment

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

the class SWCallableStatementTest method testInsertWithIntColumnIndexes.

@Test
public void testInsertWithIntColumnIndexes() throws SQLException {
    CallableStatement preparedStatement = swConnection.prepareCall("INSERT INTO test VALUES(?)");
    boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", new int[] { 1, 2 });
    preparedStatement.close();
    verify(mysqlCallableStatement, times(1)).close();
    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/CallableStatement/execute", "INSERT INTO test VALUES(1)");
}
Also used : CallableStatement(java.sql.CallableStatement) 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 27 with TraceSegment

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

the class SWCallableStatementTest method testInsertWithStringColumnIndexes.

@Test
public void testInsertWithStringColumnIndexes() throws SQLException {
    CallableStatement preparedStatement = swConnection.prepareCall("INSERT INTO test VALUES(?)");
    boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", new String[] { "1", "2" });
    preparedStatement.close();
    verify(mysqlCallableStatement, times(1)).close();
    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/CallableStatement/execute", "INSERT INTO test VALUES(1)");
}
Also used : CallableStatement(java.sql.CallableStatement) 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 28 with TraceSegment

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

the class SWCallableStatementTest method testBatch.

@Test
public void testBatch() throws SQLException, MalformedURLException {
    CallableStatement preparedStatement = multiHostConnection.prepareCall("UPDATE test SET a = ? WHERE b = ?");
    preparedStatement.setShort(1, (short) 12);
    preparedStatement.setTime(2, new Time(System.currentTimeMillis()));
    preparedStatement.addBatch();
    int[] resultSet = preparedStatement.executeBatch();
    preparedStatement.clearBatch();
    verify(mysqlCallableStatement, times(1)).executeBatch();
    verify(mysqlCallableStatement, times(1)).addBatch();
    verify(mysqlCallableStatement, times(1)).clearBatch();
    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/CallableStatement/executeBatch", "");
}
Also used : CallableStatement(java.sql.CallableStatement) AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) Time(java.sql.Time) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Example 29 with TraceSegment

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

the class SWCallableStatementTest method testUpdateWithAutoGeneratedKey.

@Test
public void testUpdateWithAutoGeneratedKey() throws SQLException {
    CallableStatement preparedStatement = swConnection.prepareCall("UPDATE test SET  a = ?");
    int updateCount = preparedStatement.executeUpdate("UPDATE test SET  a = 1", 1);
    preparedStatement.cancel();
    preparedStatement.close();
    verify(mysqlCallableStatement, times(1)).close();
    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/CallableStatement/executeUpdate", "UPDATE test SET  a = 1");
}
Also used : CallableStatement(java.sql.CallableStatement) AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) SegmentStoragePoint(org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Example 30 with TraceSegment

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

the class SWCallableStatementTest method testUpdateWithStringColumnIndexes.

@Test
public void testUpdateWithStringColumnIndexes() throws SQLException {
    CallableStatement preparedStatement = swConnection.prepareCall("UPDATE test SET  a = ?");
    int updateCount = preparedStatement.executeUpdate("UPDATE test SET  a = 1", new String[] { "1" });
    preparedStatement.cancel();
    preparedStatement.close();
    verify(mysqlCallableStatement, times(1)).close();
    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/CallableStatement/executeUpdate", "UPDATE test SET  a = 1");
}
Also used : CallableStatement(java.sql.CallableStatement) AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) SegmentStoragePoint(org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Aggregations

TraceSegment (org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)158 AbstractTracingSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan)149 Test (org.junit.Test)147 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)20 PreparedStatement (java.sql.PreparedStatement)19 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