Skip to content

Commit 237983d

Browse files
committed
wrap
1 parent eaaa8ce commit 237983d

File tree

7 files changed

+35
-35
lines changed

7 files changed

+35
-35
lines changed

instrumentation/jdbc/library/src/test/java/io/opentelemetry/instrumentation/jdbc/JdbcInstrumentationTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ protected InstrumentationExtension testing() {
3838
}
3939

4040
@Override
41-
protected Connection instrumentConnection(Connection connection) throws SQLException {
42-
return telemetryHelper.instrumentConnection(connection);
41+
protected Connection wrap(Connection connection) throws SQLException {
42+
return telemetryHelper.wrap(connection);
4343
}
4444

4545
@Override
46-
protected DataSource instrumentDataSource(DataSource dataSource) {
47-
return telemetryHelper.instrumentDataSource(dataSource);
46+
protected DataSource wrap(DataSource dataSource) {
47+
return telemetryHelper.wrap(dataSource);
4848
}
4949

5050
@Override
@@ -115,7 +115,7 @@ public Connection connect(String url, Properties info) throws SQLException {
115115
if (connection == null) {
116116
return null;
117117
}
118-
return telemetryHelper.instrumentConnection(connection);
118+
return telemetryHelper.wrap(connection);
119119
}
120120

121121
@Override

instrumentation/jdbc/library/src/test/java/io/opentelemetry/instrumentation/jdbc/LibraryJdbcTestTelemetry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class LibraryJdbcTestTelemetry {
2323
this.testing = testing;
2424
}
2525

26-
Connection instrumentConnection(Connection connection) throws SQLException {
26+
Connection wrap(Connection connection) throws SQLException {
2727
return wrapConnection(connection, telemetry());
2828
}
2929

@@ -40,7 +40,7 @@ private static Connection wrapConnection(Connection connection, JdbcTelemetry te
4040
return dataSource.getConnection();
4141
}
4242

43-
DataSource instrumentDataSource(DataSource dataSource) {
43+
DataSource wrap(DataSource dataSource) {
4444
return wrapDataSource(dataSource, telemetry());
4545
}
4646

instrumentation/jdbc/library/src/test/java/io/opentelemetry/instrumentation/jdbc/PreparedStatementParametersTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected InstrumentationExtension testing() {
2626
}
2727

2828
@Override
29-
protected Connection instrumentConnection(Connection connection) throws SQLException {
29+
protected Connection wrap(Connection connection) throws SQLException {
3030
return telemetryHelper.instrumentConnectionWithQueryParameters(connection);
3131
}
3232
}

instrumentation/jdbc/testing/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ dependencies {
1616
api("org.hsqldb:hsqldb:2.0.0")
1717

1818
api("org.apache.tomcat:tomcat-jdbc:7.0.19")
19-
api("org.apache.tomcat:tomcat-juli:7.0.19")
2019
api("com.zaxxer:HikariCP:2.4.0")
2120
api("com.mchange:c3p0:0.9.5")
2221
}

instrumentation/jdbc/testing/src/main/java/io/opentelemetry/instrumentation/jdbc/TestConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
/** A JDBC connection class that optionally throws an exception in the constructor, used to test */
3030
public class TestConnection implements Connection {
31-
private String url;
31+
32+
private final String url;
3233
Consumer<String> sqlConsumer = unused -> {};
3334

3435
public TestConnection() {}

instrumentation/jdbc/testing/src/main/java/io/opentelemetry/instrumentation/jdbc/testing/AbstractJdbcInstrumentationTest.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ public abstract class AbstractJdbcInstrumentationTest {
8282

8383
protected abstract InstrumentationExtension testing();
8484

85-
protected Connection instrumentConnection(Connection connection) throws SQLException {
85+
protected Connection wrap(Connection connection) throws SQLException {
8686
return connection;
8787
}
8888

89-
protected DataSource instrumentDataSource(DataSource dataSource) {
89+
protected DataSource wrap(DataSource dataSource) {
9090
return dataSource;
9191
}
9292

@@ -376,7 +376,7 @@ public void testBasicStatement(
376376
String url,
377377
String table)
378378
throws SQLException {
379-
connection = instrumentConnection(connection);
379+
connection = wrap(connection);
380380
Statement statement = connection.createStatement();
381381
cleanup.deferCleanup(statement);
382382
ResultSet resultSet = testing().runWithSpan("parent", () -> statement.executeQuery(query));
@@ -505,7 +505,7 @@ void testPreparedStatementExecute(
505505
String url,
506506
String table)
507507
throws SQLException {
508-
connection = instrumentConnection(connection);
508+
connection = wrap(connection);
509509
PreparedStatement statement = connection.prepareStatement(query);
510510
cleanup.deferCleanup(statement);
511511
ResultSet resultSet =
@@ -552,7 +552,7 @@ void testPreparedStatementQuery(
552552
String url,
553553
String table)
554554
throws SQLException {
555-
connection = instrumentConnection(connection);
555+
connection = wrap(connection);
556556
PreparedStatement statement = connection.prepareStatement(query);
557557
cleanup.deferCleanup(statement);
558558
ResultSet resultSet = testing().runWithSpan("parent", () -> statement.executeQuery());
@@ -592,7 +592,7 @@ void testPreparedCall(
592592
String url,
593593
String table)
594594
throws SQLException {
595-
connection = instrumentConnection(connection);
595+
connection = wrap(connection);
596596
CallableStatement statement = connection.prepareCall(query);
597597
cleanup.deferCleanup(statement);
598598
ResultSet resultSet = testing().runWithSpan("parent", () -> statement.executeQuery());
@@ -731,7 +731,7 @@ void testStatementUpdate(
731731
String url,
732732
String table)
733733
throws SQLException {
734-
connection = instrumentConnection(connection);
734+
connection = wrap(connection);
735735
Statement statement = connection.createStatement();
736736
cleanup.deferCleanup(statement);
737737
String sql = connection.nativeSQL(query);
@@ -909,7 +909,7 @@ void testPreparedStatementUpdateImpl(
909909
String table,
910910
ThrowingConsumer<PreparedStatement> action)
911911
throws SQLException {
912-
connection = instrumentConnection(connection);
912+
connection = wrap(connection);
913913
String sql = connection.nativeSQL(query);
914914
PreparedStatement statement = connection.prepareStatement(sql);
915915
cleanup.deferCleanup(statement);
@@ -1083,7 +1083,7 @@ void testGetConnection(
10831083
if (init != null) {
10841084
init.accept(datasource);
10851085
}
1086-
DataSource instrumentedDatasource = instrumentDataSource(datasource);
1086+
DataSource instrumentedDatasource = wrap(datasource);
10871087
instrumentedDatasource.getConnection().close();
10881088
assertThat(testing().spans()).noneMatch(span -> span.getName().equals("database.connection"));
10891089

@@ -1126,7 +1126,7 @@ void testGetConnection(
11261126
@ValueSource(strings = "testing 123")
11271127
void testGetClientInfoException(String query) throws SQLException {
11281128
TestConnection rawConnection = new TestConnection("jdbc:testdb://localhost", false);
1129-
Connection connection = instrumentConnection(rawConnection);
1129+
Connection connection = wrap(rawConnection);
11301130
cleanup.deferCleanup(connection);
11311131

11321132
Statement statement =
@@ -1214,7 +1214,7 @@ void testProduceProperSpanName(
12141214
String table)
12151215
throws SQLException {
12161216
Driver driver = new TestDriver();
1217-
Connection connection = instrumentConnection(driver.connect(url, null));
1217+
Connection connection = wrap(driver.connect(url, null));
12181218
cleanup.deferCleanup(connection);
12191219

12201220
Connection finalConnection = connection;
@@ -1253,7 +1253,7 @@ void testProduceProperSpanName(
12531253
void testConnectionCached(String connectionPoolName) throws SQLException {
12541254
String dbType = "hsqldb";
12551255
DataSource rawDataSource = createDs(connectionPoolName, dbType, jdbcUrls.get(dbType));
1256-
DataSource dataSource = instrumentDataSource(rawDataSource);
1256+
DataSource dataSource = wrap(rawDataSource);
12571257
DataSource finalDataSource = dataSource;
12581258
cleanup.deferCleanup(
12591259
() -> {
@@ -1347,7 +1347,7 @@ void testHandleRecursiveStatements(
13471347
throws Exception {
13481348
DbCallingConnection rawConnection =
13491349
new DbCallingConnection(usePreparedStatementInConnection, "jdbc:testdb://localhost");
1350-
Connection connection = instrumentConnection(rawConnection);
1350+
Connection connection = wrap(rawConnection);
13511351

13521352
testing()
13531353
.runWithSpan(
@@ -1382,7 +1382,7 @@ void testHandleRecursiveStatements(
13821382
@Test
13831383
void testProxyStatement() throws Exception {
13841384
Connection connection =
1385-
instrumentConnection(new org.h2.Driver().connect(jdbcUrls.get("h2"), null));
1385+
wrap(new org.h2.Driver().connect(jdbcUrls.get("h2"), null));
13861386
Statement statement = connection.createStatement();
13871387
cleanup.deferCleanup(statement);
13881388
cleanup.deferCleanup(connection);
@@ -1410,7 +1410,7 @@ void testProxyStatement() throws Exception {
14101410
@Test
14111411
void testProxyPreparedStatement() throws SQLException {
14121412
Connection connection =
1413-
instrumentConnection(new org.h2.Driver().connect(jdbcUrls.get("h2"), null));
1413+
wrap(new org.h2.Driver().connect(jdbcUrls.get("h2"), null));
14141414
PreparedStatement statement = connection.prepareStatement("SELECT 3");
14151415
cleanup.deferCleanup(statement);
14161416
cleanup.deferCleanup(connection);
@@ -1480,7 +1480,7 @@ private void testBatchImpl(
14801480
String tableName,
14811481
ThrowingConsumer<Statement> action)
14821482
throws SQLException {
1483-
connection = instrumentConnection(connection);
1483+
connection = wrap(connection);
14841484
Statement createTable = connection.createStatement();
14851485
createTable.execute("CREATE TABLE " + tableName + " (id INTEGER not NULL, PRIMARY KEY ( id ))");
14861486
cleanup.deferCleanup(createTable);
@@ -1534,7 +1534,7 @@ DB_CONNECTION_STRING, emitStableDatabaseSemconv() ? null : url),
15341534
@MethodSource("batchStream")
15351535
void testMultiBatch(String system, Connection connection, String username, String url)
15361536
throws SQLException {
1537-
connection = instrumentConnection(connection);
1537+
connection = wrap(connection);
15381538
String tableName1 = "multi_batch_test_1";
15391539
String tableName2 = "multi_batch_test_2";
15401540
Statement createTable1 = connection.createStatement();
@@ -1594,7 +1594,7 @@ DB_CONNECTION_STRING, emitStableDatabaseSemconv() ? null : url),
15941594
@MethodSource("batchStream")
15951595
void testSingleItemBatch(String system, Connection connection, String username, String url)
15961596
throws SQLException {
1597-
connection = instrumentConnection(connection);
1597+
connection = wrap(connection);
15981598
String tableName = "single_item_batch_test";
15991599
Statement createTable = connection.createStatement();
16001600
createTable.execute("CREATE TABLE " + tableName + " (id INTEGER not NULL, PRIMARY KEY ( id ))");
@@ -1635,7 +1635,7 @@ DB_CONNECTION_STRING, emitStableDatabaseSemconv() ? null : url),
16351635
@MethodSource("batchStream")
16361636
void testPreparedBatch(String system, Connection connection, String username, String url)
16371637
throws SQLException {
1638-
connection = instrumentConnection(connection);
1638+
connection = wrap(connection);
16391639
String tableName = "prepared_batch_test";
16401640
Statement createTable = connection.createStatement();
16411641
createTable.execute("CREATE TABLE " + tableName + " (id INTEGER not NULL, PRIMARY KEY ( id ))");
@@ -1709,7 +1709,7 @@ void testSqlCommenterNotEnabled() throws SQLException {
17091709
@MethodSource("transactionOperationsStream")
17101710
void testCommitTransaction(String system, Connection connection, String username, String url)
17111711
throws SQLException {
1712-
Connection instrumentedConnection = instrumentConnection(connection);
1712+
Connection instrumentedConnection = wrap(connection);
17131713
Connection finalConnection = instrumentedConnection;
17141714

17151715
String tableName = "TXN_COMMIT_TEST_" + system.toUpperCase(Locale.ROOT);
@@ -1771,7 +1771,7 @@ DB_CONNECTION_STRING, emitStableDatabaseSemconv() ? null : url),
17711771
@MethodSource("transactionOperationsStream")
17721772
void testRollbackTransaction(String system, Connection connection, String username, String url)
17731773
throws SQLException {
1774-
Connection instrumentedConnection = instrumentConnection(connection);
1774+
Connection instrumentedConnection = wrap(connection);
17751775
Connection finalConnection = instrumentedConnection;
17761776

17771777
String tableName = "TXN_ROLLBACK_TEST_" + system.toUpperCase(Locale.ROOT);
@@ -1864,7 +1864,7 @@ private PreparedStatement wrapPreparedStatement(PreparedStatement statement) {
18641864
@Test
18651865
void testPreparedStatementWrapper() throws SQLException {
18661866
Connection connection =
1867-
instrumentConnection(new org.h2.Driver().connect(jdbcUrls.get("h2"), null));
1867+
wrap(new org.h2.Driver().connect(jdbcUrls.get("h2"), null));
18681868
Connection proxyConnection =
18691869
ProxyStatementFactory.proxy(
18701870
Connection.class,
@@ -1905,7 +1905,7 @@ void testPreparedStatementWrapper() throws SQLException {
19051905
@Test
19061906
void testStatementWrapper() throws SQLException {
19071907
Connection connection =
1908-
instrumentConnection(new org.h2.Driver().connect(jdbcUrls.get("h2"), null));
1908+
wrap(new org.h2.Driver().connect(jdbcUrls.get("h2"), null));
19091909
Statement statement = connection.createStatement();
19101910
cleanup.deferCleanup(statement);
19111911
cleanup.deferCleanup(connection);

instrumentation/jdbc/testing/src/main/java/io/opentelemetry/instrumentation/jdbc/testing/AbstractPreparedStatementParametersTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public abstract class AbstractPreparedStatementParametersTest {
5353

5454
protected abstract InstrumentationExtension testing();
5555

56-
protected Connection instrumentConnection(Connection connection) throws SQLException {
56+
protected Connection wrap(Connection connection) throws SQLException {
5757
return connection;
5858
}
5959

@@ -571,7 +571,7 @@ private void test(
571571
ThrowingConsumer<PreparedStatement, SQLException> setParameter,
572572
String expectedParameterValue)
573573
throws SQLException {
574-
Connection instrumentedConnection = instrumentConnection(connection);
574+
Connection instrumentedConnection = wrap(connection);
575575
PreparedStatement statement = instrumentedConnection.prepareStatement(query);
576576
cleanup.deferCleanup(statement);
577577

0 commit comments

Comments
 (0)