Skip to content

Commit 0f5dbbc

Browse files
committed
address review comment
1 parent f0306ce commit 0f5dbbc

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/OpenTelemetryPreparedStatement.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,4 +364,14 @@ public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
364364
public void clearParameters() throws SQLException {
365365
delegate.clearParameters();
366366
}
367+
368+
@Override
369+
public int[] executeBatch() throws SQLException {
370+
return wrapBatchCall(delegate::executeBatch);
371+
}
372+
373+
private <T, E extends Exception> T wrapBatchCall(ThrowingSupplier<T, E> callable) throws E {
374+
DbRequest request = DbRequest.create(dbInfo, query, batchSize);
375+
return wrapCall(request, callable);
376+
}
367377
}

instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/OpenTelemetryStatement.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
2626
import io.opentelemetry.instrumentation.jdbc.internal.dbinfo.DbInfo;
2727
import java.sql.Connection;
28-
import java.sql.PreparedStatement;
2928
import java.sql.ResultSet;
3029
import java.sql.SQLException;
3130
import java.sql.SQLWarning;
@@ -300,7 +299,7 @@ protected <T, E extends Exception> T wrapCall(String sql, ThrowingSupplier<T, E>
300299
return wrapCall(request, callable);
301300
}
302301

303-
private <T, E extends Exception> T wrapCall(DbRequest request, ThrowingSupplier<T, E> callable)
302+
protected <T, E extends Exception> T wrapCall(DbRequest request, ThrowingSupplier<T, E> callable)
304303
throws E {
305304
Context parentContext = Context.current();
306305

@@ -320,11 +319,8 @@ private <T, E extends Exception> T wrapCall(DbRequest request, ThrowingSupplier<
320319
return result;
321320
}
322321

323-
protected <T, E extends Exception> T wrapBatchCall(ThrowingSupplier<T, E> callable) throws E {
324-
DbRequest request =
325-
this instanceof PreparedStatement
326-
? DbRequest.create(dbInfo, query, batchSize)
327-
: DbRequest.create(dbInfo, batchCommands, batchSize);
322+
private <T, E extends Exception> T wrapBatchCall(ThrowingSupplier<T, E> callable) throws E {
323+
DbRequest request = DbRequest.create(dbInfo, batchCommands, batchSize);
328324
return wrapCall(request, callable);
329325
}
330326
}

0 commit comments

Comments
 (0)