Skip to content

Commit 5ea99d5

Browse files
otelbot[bot]Copilottrask
authored
Review fixes for jdbc:testing (#18151)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: trask <218610+trask@users.noreply.github.com>
1 parent f3840b0 commit 5ea99d5

5 files changed

Lines changed: 19 additions & 14 deletions

File tree

instrumentation/jdbc/metadata.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,23 @@ semantic_conventions:
1111
library_link: https://docs.oracle.com/javase/8/docs/api/java/sql/package-summary.html
1212
configurations:
1313
- name: otel.instrumentation.jdbc.query-sanitization.enabled
14+
declarative_name: java.jdbc.query_sanitization.enabled
1415
description: Enables query sanitization for database queries. Takes precedence over
1516
otel.instrumentation.common.db.query-sanitization.enabled.
1617
type: boolean
1718
default: true
1819
- name: otel.instrumentation.common.db.query-sanitization.enabled
20+
declarative_name: java.common.db.query_sanitization.enabled
1921
description: Enables query sanitization for database queries.
2022
type: boolean
2123
default: true
2224
- name: otel.instrumentation.jdbc.experimental.transaction.enabled
25+
declarative_name: java.jdbc.transaction/development.enabled
2326
description: Enables experimental instrumentation to create spans for COMMIT and ROLLBACK operations.
2427
type: boolean
2528
default: false
2629
- name: otel.instrumentation.jdbc.experimental.sqlcommenter.enabled
30+
declarative_name: java.jdbc.sqlcommenter/development.enabled
2731
description: >
2832
Enables augmenting queries with a comment containing the tracing information. See
2933
[sqlcommenter](https://google.github.io/sqlcommenter/) for more info. WARNING: augmenting
@@ -36,6 +40,7 @@ configurations:
3640
type: map
3741
default: ""
3842
- name: otel.instrumentation.jdbc.experimental.capture-query-parameters
43+
declarative_name: java.jdbc.capture_query_parameters/development
3944
description: >
4045
Sets whether the query parameters should be captured as span attributes named
4146
<code>db.query.parameter.&lt;key&gt;</code>. Enabling this option disables the statement
@@ -44,6 +49,7 @@ configurations:
4449
type: boolean
4550
default: false
4651
- name: otel.instrumentation.jdbc-datasource.enabled
52+
declarative_name: java.jdbc_datasource.enabled
4753
description: Enables instrumentation of JDBC datasource connections.
4854
type: boolean
4955
default: false

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,8 +1503,8 @@ void testConnectionCached(String connectionPoolName) throws SQLException {
15031503
}
15041504

15051505
@FunctionalInterface
1506-
public interface ThrowingBiConsumer<T, U> {
1507-
void accept(T t, U u) throws Exception;
1506+
private interface ThrowingBiConsumer<T, U> {
1507+
void accept(T t, U u) throws SQLException;
15081508
}
15091509

15101510
static Stream<Arguments> recursiveStatementsStream() {
@@ -1539,7 +1539,7 @@ void testHandleRecursiveStatements(
15391539
String desc,
15401540
boolean usePreparedStatementInConnection,
15411541
ThrowingBiConsumer<Connection, String> executeQueryFunction)
1542-
throws Exception {
1542+
throws SQLException {
15431543
Connection connection =
15441544
wrap(new DbCallingConnection(usePreparedStatementInConnection, "jdbc:testdb://localhost"));
15451545

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ DB_CONNECTION_STRING, emitStableDatabaseSemconv() ? null : url),
644644
expectedParameterValue))));
645645
}
646646

647-
public interface ThrowingConsumer<T, E extends Throwable> {
647+
private interface ThrowingConsumer<T, E extends Throwable> {
648648
void accept(T t) throws E;
649649
}
650650
}

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
import java.sql.PreparedStatement;
1313
import java.sql.Statement;
1414

15-
public class ProxyStatementFactory {
15+
class ProxyStatementFactory {
1616

17-
public static Statement proxyStatementWithCustomClassLoader(Statement statement)
18-
throws Exception {
17+
static Statement proxyStatementWithCustomClassLoader(Statement statement) throws Exception {
1918
TestClassLoader classLoader = new TestClassLoader(ProxyStatementFactory.class.getClassLoader());
2019
Class<?> testInterface = classLoader.loadClass(TestInterface.class.getName());
2120
if (testInterface.getClassLoader() != classLoader) {
@@ -30,17 +29,17 @@ public static Statement proxyStatementWithCustomClassLoader(Statement statement)
3029
invocationHandler);
3130
}
3231

33-
public static Statement proxyStatement(InvocationHandler invocationHandler) {
32+
static Statement proxyStatement(InvocationHandler invocationHandler) {
3433
return proxy(Statement.class, invocationHandler);
3534
}
3635

37-
public static PreparedStatement proxyPreparedStatement(PreparedStatement statement) {
36+
static PreparedStatement proxyPreparedStatement(PreparedStatement statement) {
3837
InvocationHandler invocationHandler =
3938
(proxy, method, args) -> invokeWithUnwrappedTarget(statement, method, args);
4039
return proxyPreparedStatement(invocationHandler);
4140
}
4241

43-
public static PreparedStatement proxyPreparedStatement(InvocationHandler invocationHandler) {
42+
static PreparedStatement proxyPreparedStatement(InvocationHandler invocationHandler) {
4443
return proxy(PreparedStatement.class, invocationHandler);
4544
}
4645

@@ -58,15 +57,15 @@ private static Object invokeWithUnwrappedTarget(Object target, Method method, Ob
5857
}
5958
}
6059

61-
public static <T> T proxy(Class<T> clazz, InvocationHandler invocationHandler) {
60+
static <T> T proxy(Class<T> clazz, InvocationHandler invocationHandler) {
6261
return proxy(
6362
clazz,
6463
ProxyStatementFactory.class.getClassLoader(),
6564
new Class<?>[] {clazz, TestInterface.class},
6665
invocationHandler);
6766
}
6867

69-
public static <T> T proxy(
68+
static <T> T proxy(
7069
Class<T> clazz,
7170
ClassLoader classLoader,
7271
Class<?>[] interfaces,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import java.net.URL;
99
import java.net.URLClassLoader;
1010

11-
public class TestClassLoader extends URLClassLoader {
11+
class TestClassLoader extends URLClassLoader {
1212

13-
public TestClassLoader(ClassLoader parent) {
13+
TestClassLoader(ClassLoader parent) {
1414
super(
1515
new URL[] {TestClassLoader.class.getProtectionDomain().getCodeSource().getLocation()},
1616
parent);

0 commit comments

Comments
 (0)