@@ -1684,83 +1684,11 @@ DB_CONNECTION_STRING, emitStableDatabaseSemconv() ? null : url),
16841684 equalTo (
16851685 DB_OPERATION_BATCH_SIZE ,
16861686 emitStableDatabaseSemconv () ? 2L : null ),
1687- // Different tables in batch means summary is just operation
16881687 equalTo (
16891688 DB_QUERY_SUMMARY ,
16901689 emitStableDatabaseSemconv () ? "BATCH INSERT" : null ))));
16911690 }
16921691
1693- @ ParameterizedTest
1694- @ MethodSource ("batchStream" )
1695- void testHeterogeneousBatch (String system , Connection conn , String username , String url )
1696- throws SQLException {
1697- Connection connection = wrap (conn );
1698- String tableName = "hetero_batch_test" ;
1699- Statement createTable = connection .createStatement ();
1700- createTable .execute ("CREATE TABLE " + tableName + " (id INTEGER not NULL, PRIMARY KEY ( id ))" );
1701- cleanup .deferCleanup (createTable );
1702-
1703- // Insert a row first so we can delete it
1704- Statement insertFirst = connection .createStatement ();
1705- insertFirst .execute ("INSERT INTO " + tableName + " VALUES(99)" );
1706- cleanup .deferCleanup (insertFirst );
1707-
1708- testing ().waitForTraces (2 );
1709- testing ().clearData ();
1710-
1711- Statement statement = connection .createStatement ();
1712- cleanup .deferCleanup (statement );
1713- // Batch with different operations: INSERT and DELETE
1714- statement .addBatch ("INSERT INTO " + tableName + " VALUES(1)" );
1715- statement .addBatch ("DELETE FROM " + tableName + " WHERE id=99" );
1716- testing ()
1717- .runWithSpan (
1718- "parent" , () -> assertThat (statement .executeBatch ()).isEqualTo (new int [] {1 , 1 }));
1719-
1720- testing ()
1721- .waitAndAssertTraces (
1722- trace ->
1723- trace .hasSpansSatisfyingExactly (
1724- span -> span .hasName ("parent" ).hasKind (SpanKind .INTERNAL ).hasNoParent (),
1725- span ->
1726- span .hasName (
1727- emitStableDatabaseSemconv ()
1728- ? "BATCH " + dbNameLower + "." + tableName
1729- : "jdbcunittest" )
1730- .hasKind (SpanKind .CLIENT )
1731- .hasParent (trace .getSpan (0 ))
1732- .hasAttributesSatisfyingExactly (
1733- equalTo (maybeStable (DB_SYSTEM ), maybeStableDbSystemName (system )),
1734- equalTo (maybeStable (DB_NAME ), dbNameLower ),
1735- equalTo (DB_USER , emitStableDatabaseSemconv () ? null : username ),
1736- equalTo (
1737- DB_CONNECTION_STRING , emitStableDatabaseSemconv () ? null : url ),
1738- equalTo (
1739- maybeStable (DB_STATEMENT ),
1740- emitStableDatabaseSemconv ()
1741- ? "INSERT INTO "
1742- + tableName
1743- + " VALUES(?); DELETE FROM "
1744- + tableName
1745- + " WHERE id=?"
1746- : null ),
1747- // Operation is "BATCH" because operations differ (INSERT vs DELETE)
1748- equalTo (
1749- maybeStable (DB_OPERATION ),
1750- emitStableDatabaseSemconv () ? "BATCH" : null ),
1751- // Table is set because both statements target the same table
1752- equalTo (
1753- maybeStable (DB_SQL_TABLE ),
1754- emitStableDatabaseSemconv () ? tableName : null ),
1755- equalTo (
1756- DB_OPERATION_BATCH_SIZE ,
1757- emitStableDatabaseSemconv () ? 2L : null ),
1758- // Query summary is "BATCH" because operations differ
1759- equalTo (
1760- DB_QUERY_SUMMARY ,
1761- emitStableDatabaseSemconv () ? "BATCH" : null ))));
1762- }
1763-
17641692 @ ParameterizedTest
17651693 @ MethodSource ("batchStream" )
17661694 void testSingleItemBatch (String system , Connection conn , String username , String url )
0 commit comments