From 6eea03bb4993b3bfc58c5e96037b147e934a20ac Mon Sep 17 00:00:00 2001 From: Keshav Dandeva Date: Tue, 4 Aug 2026 14:29:05 +0000 Subject: [PATCH 1/5] chore: add debug statements --- .../jdbc/OpenTelemetryJulHandler.java | 10 +- .../bigquery/jdbc/it/ITOpenTelemetryTest.java | 91 ++++++++++++++++++- 2 files changed, 95 insertions(+), 6 deletions(-) diff --git a/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/OpenTelemetryJulHandler.java b/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/OpenTelemetryJulHandler.java index af5e5278ffb6..0edd2b0300d8 100644 --- a/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/OpenTelemetryJulHandler.java +++ b/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/OpenTelemetryJulHandler.java @@ -78,7 +78,10 @@ public void publish(LogRecord record) { publishToOTel(record, connectionId, config.openTelemetry); } } catch (Throwable t) { - // Ignore exceptions to prevent breaking application logging or other handlers + reportError( + "Error publishing log to OpenTelemetry/GCP", + new Exception(t), + java.util.logging.ErrorManager.WRITE_FAILURE); } } @@ -182,7 +185,10 @@ public void flush() { try { config.loggingClient.flush(); } catch (Exception e) { - // Ignore failures during flush to protect other connections + reportError( + "Error flushing log to OpenTelemetry/GCP", + e, + java.util.logging.ErrorManager.FLUSH_FAILURE); } } } diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java index 8bdf20ec90e1..872d676a1ae7 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java @@ -56,6 +56,7 @@ public class ITOpenTelemetryTest extends ITBase { @Test public void testExecute_withOpenTelemetryGcpExporter() throws Exception { + System.out.println("[DEBUG_IT] === Starting testExecute_withOpenTelemetryGcpExporter ==="); // Step 1: Connect with GCP Exporters enabled via DataSource DataSource ds = DataSource.fromUrl(CONNECTION_URL); @@ -75,6 +76,7 @@ public void testExecute_withOpenTelemetryGcpExporter() throws Exception { BigQueryConnection bqConnection = connection.unwrap(BigQueryConnection.class); connectionUuid = bqConnection.getConnectionId(); assertNotNull(connectionUuid, "Connection UUID should be generated"); + System.out.println("[DEBUG_IT] Generated connectionUuid: " + connectionUuid); // Execute an in-memory array query (scans 0 bytes, extremely fast) and force pagination (3 // pages) @@ -84,6 +86,9 @@ public void testExecute_withOpenTelemetryGcpExporter() throws Exception { // Drain the result set to trigger pagination fetches } } + System.out.println( + "[DEBUG_IT] Query executed. Waiting for logs and traces for connectionUuid: " + + connectionUuid); } // Step 2: Retrieve and assert logs, harvesting the TraceId @@ -127,6 +132,7 @@ public void testExecute_withOpenTelemetryGcpExporter() throws Exception { @Test public void testExecute_withErrorCorrelation() throws Exception { + System.out.println("[DEBUG_IT] === Starting testExecute_withErrorCorrelation ==="); // Step 1: Connect with GCP Exporters enabled via DataSource DataSource ds = DataSource.fromUrl(CONNECTION_URL); @@ -144,9 +150,13 @@ public void testExecute_withErrorCorrelation() throws Exception { BigQueryConnection bqConnection = connection.unwrap(BigQueryConnection.class); connectionUuid = bqConnection.getConnectionId(); assertNotNull(connectionUuid, "Connection UUID should be generated"); + System.out.println("[DEBUG_IT] Generated connectionUuid: " + connectionUuid); // Execute a query designed to fail instantly due to syntax error (compiler-level failure) assertThrows(SQLException.class, () -> statement.executeQuery("SELECT * FROM;")); + System.out.println( + "[DEBUG_IT] Expected SQLException caught. Waiting for logs and traces for connectionUuid: " + + connectionUuid); } // Step 2: Retrieve and assert logs, harvesting the TraceId @@ -171,6 +181,7 @@ public void testExecute_withErrorCorrelation() throws Exception { @Test public void testExecute_withCustomCredentialsJson() throws Exception { + System.out.println("[DEBUG_IT] === Starting testExecute_withCustomCredentialsJson ==="); JsonObject authJson = getAuthJson(); DataSource ds = DataSource.fromUrl(CONNECTION_URL); ds.setEnableGcpTraceExporter(true); @@ -182,6 +193,7 @@ public void testExecute_withCustomCredentialsJson() throws Exception { @Test public void testExecute_withCustomCredentialsFilePath() throws Exception { + System.out.println("[DEBUG_IT] === Starting testExecute_withCustomCredentialsFilePath ==="); JsonObject authJson = getAuthJson(); File tempFile = File.createTempFile("auth", ".json"); tempFile.deleteOnExit(); @@ -197,6 +209,7 @@ public void testExecute_withCustomCredentialsFilePath() throws Exception { @Test public void testExecute_withHttpProtocol() throws Exception { + System.out.println("[DEBUG_IT] === Starting testExecute_withHttpProtocol ==="); JsonObject authJson = getAuthJson(); System.setProperty("otel.exporter.otlp.protocol", "http/protobuf"); @@ -214,6 +227,7 @@ public void testExecute_withHttpProtocol() throws Exception { @Test public void testExecute_withGrpcProtocol() throws Exception { + System.out.println("[DEBUG_IT] === Starting testExecute_withGrpcProtocol ==="); JsonObject authJson = getAuthJson(); System.setProperty("otel.exporter.otlp.protocol", "grpc"); @@ -239,6 +253,7 @@ private void verifyTraceDelivery(DataSource ds) throws Exception { BigQueryConnection bqConnection = connection.unwrap(BigQueryConnection.class); connectionUuid = bqConnection.getConnectionId(); + System.out.println("[DEBUG_IT] verifyTraceDelivery connectionUuid: " + connectionUuid); String query = "SELECT 1;"; try (ResultSet rs = statement.executeQuery(query)) { @@ -307,46 +322,95 @@ private Trace verifyAndFetchTrace(String traceId) throws Exception { } } - private T pollWithRetry(java.util.concurrent.Callable task) throws InterruptedException { + private T pollWithRetry(String taskDescription, java.util.concurrent.Callable task) + throws InterruptedException { int attempts = 0; int maxAttempts = 24; long delayMs = 10000; + System.out.println( + "[DEBUG_IT] [" + + taskDescription + + "] Starting polling (maxAttempts=" + + maxAttempts + + ", delayMs=" + + delayMs + + "). Waiting 10 seconds initially..."); // 10 second wait for GCP to ingest data Thread.sleep(10000); while (attempts < maxAttempts) { attempts++; + System.out.println( + "[DEBUG_IT] [" + taskDescription + "] Attempt " + attempts + "/" + maxAttempts); try { T result = task.call(); if (result != null) { + System.out.println( + "[DEBUG_IT] [" + + taskDescription + + "] Succeeded on attempt " + + attempts + + "/" + + maxAttempts); return result; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException("Test execution interrupted", e); } catch (Exception e) { - // Ignore exceptions during remote lookup and retry + System.err.println( + "[DEBUG_IT] [" + + taskDescription + + "] Exception on attempt " + + attempts + + ": " + + e.getClass().getName() + + " - " + + e.getMessage()); e.printStackTrace(); } if (attempts < maxAttempts) { Thread.sleep(delayMs); } } + System.err.println( + "[DEBUG_IT] [" + taskDescription + "] Timed out after " + maxAttempts + " attempts."); return null; } private List fetchLogsWithRetry(Logging logging, String filter) throws InterruptedException { + System.out.println("[DEBUG_IT] Polling GCP Cloud Logging with filter: " + filter); List result = pollWithRetry( + "fetchLogsWithRetry (" + filter + ")", () -> { Page entriesPage = logging.listLogEntries( Logging.EntryListOption.filter(filter), Logging.EntryListOption.pageSize(50)); List entries = new ArrayList<>(); entriesPage.iterateAll().forEach(entries::add); - return entries.isEmpty() ? null : entries; + if (entries.isEmpty()) { + System.out.println("[DEBUG_IT] -> Found 0 matching log entries."); + return null; + } + System.out.println( + "[DEBUG_IT] -> Found " + entries.size() + " matching log entries:"); + for (LogEntry entry : entries) { + System.out.println( + "[DEBUG_IT] LogEntry: logName=" + + entry.getLogName() + + ", trace=" + + entry.getTrace() + + ", spanId=" + + entry.getSpanId() + + ", labels=" + + entry.getLabels() + + ", payload=" + + entry.getPayload()); + } + return entries; }); return result != null ? result : new ArrayList<>(); } @@ -354,17 +418,36 @@ private List fetchLogsWithRetry(Logging logging, String filter) private Trace fetchTraceWithRetry( TraceServiceClient traceClient, String projectId, String traceId) throws InterruptedException { + System.out.println( + "[DEBUG_IT] Polling GCP Cloud Trace with projectId=" + projectId + ", traceId=" + traceId); return pollWithRetry( + "fetchTraceWithRetry (" + traceId + ")", () -> { Trace trace = traceClient.getTrace(projectId, traceId); if (trace == null) { + System.out.println("[DEBUG_IT] -> traceClient.getTrace returned null."); return null; } + System.out.println( + "[DEBUG_IT] -> Found trace with " + trace.getSpansCount() + " spans:"); + boolean foundExecuteQuery = false; for (TraceSpan span : trace.getSpansList()) { + System.out.println( + "[DEBUG_IT] Span: name=" + + span.getName() + + ", spanId=" + + span.getSpanId() + + ", parentSpanId=" + + span.getParentSpanId()); if (span.getName().equals("BigQueryStatement.executeQuery")) { - return trace; + foundExecuteQuery = true; } } + if (foundExecuteQuery) { + return trace; + } + System.out.println( + "[DEBUG_IT] -> Trace present, but 'BigQueryStatement.executeQuery' span not yet found."); return null; }); } From d19142d907a8130414523f21101a9dca8c887b91 Mon Sep 17 00:00:00 2001 From: Keshav Dandeva Date: Tue, 4 Aug 2026 14:56:14 +0000 Subject: [PATCH 2/5] remove excluded tag --- .../com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java index 872d676a1ae7..9cab70c1d89d 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java @@ -45,10 +45,9 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.List; -import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -@Tag("known_issue") // b/539615312 +// @Tag("known_issue") // b/539615312 public class ITOpenTelemetryTest extends ITBase { private static final String PROJECT_ID = ServiceOptions.getDefaultProjectId(); From ec4d52985b2573df91213d016ebbeaac040342fa Mon Sep 17 00:00:00 2001 From: Keshav Dandeva Date: Tue, 4 Aug 2026 16:49:32 +0000 Subject: [PATCH 3/5] fix removal of log handler --- .../com/google/cloud/bigquery/jdbc/BigQueryConnection.java | 1 + .../google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java b/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java index bee7d08e8607..a4aee6142f40 100644 --- a/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java +++ b/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryConnection.java @@ -1185,6 +1185,7 @@ void removeStatement(Statement statement) { } private OpenTelemetry getOpenTelemetryInstance() { + BigQueryJdbcOpenTelemetry.ensureGlobalHandlerAttached(); String effectiveProjectId = (this.gcpTelemetryProjectId != null) ? this.gcpTelemetryProjectId : this.catalog; diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java index ecffb1aa25c9..cae03f1a359a 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java @@ -2808,8 +2808,11 @@ public void testPerConnectionLoggingE2E() throws SQLException, IOException { java.util.logging.Logger bqLogger = java.util.logging.Logger.getLogger("com.google.cloud.bigquery"); for (java.util.logging.Handler h : bqLogger.getHandlers()) { - h.close(); - bqLogger.removeHandler(h); + if (h instanceof java.util.logging.FileHandler + || h.getClass().getName().endsWith("PerConnectionFileHandler")) { + h.close(); + bqLogger.removeHandler(h); + } } // Verify physical connection-specific log file creation From 1691cd76e3fa08055a1d2f834ca33dc1e584ec1d Mon Sep 17 00:00:00 2001 From: Keshav Dandeva Date: Tue, 4 Aug 2026 20:13:42 +0000 Subject: [PATCH 4/5] remove debug lines --- .../bigquery/jdbc/it/ITOpenTelemetryTest.java | 92 +------------------ 1 file changed, 4 insertions(+), 88 deletions(-) diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java index 9cab70c1d89d..4ffb4c9aed1b 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java @@ -47,7 +47,6 @@ import java.util.List; import org.junit.jupiter.api.Test; -// @Tag("known_issue") // b/539615312 public class ITOpenTelemetryTest extends ITBase { private static final String PROJECT_ID = ServiceOptions.getDefaultProjectId(); @@ -55,7 +54,6 @@ public class ITOpenTelemetryTest extends ITBase { @Test public void testExecute_withOpenTelemetryGcpExporter() throws Exception { - System.out.println("[DEBUG_IT] === Starting testExecute_withOpenTelemetryGcpExporter ==="); // Step 1: Connect with GCP Exporters enabled via DataSource DataSource ds = DataSource.fromUrl(CONNECTION_URL); @@ -75,7 +73,6 @@ public void testExecute_withOpenTelemetryGcpExporter() throws Exception { BigQueryConnection bqConnection = connection.unwrap(BigQueryConnection.class); connectionUuid = bqConnection.getConnectionId(); assertNotNull(connectionUuid, "Connection UUID should be generated"); - System.out.println("[DEBUG_IT] Generated connectionUuid: " + connectionUuid); // Execute an in-memory array query (scans 0 bytes, extremely fast) and force pagination (3 // pages) @@ -85,9 +82,6 @@ public void testExecute_withOpenTelemetryGcpExporter() throws Exception { // Drain the result set to trigger pagination fetches } } - System.out.println( - "[DEBUG_IT] Query executed. Waiting for logs and traces for connectionUuid: " - + connectionUuid); } // Step 2: Retrieve and assert logs, harvesting the TraceId @@ -131,7 +125,6 @@ public void testExecute_withOpenTelemetryGcpExporter() throws Exception { @Test public void testExecute_withErrorCorrelation() throws Exception { - System.out.println("[DEBUG_IT] === Starting testExecute_withErrorCorrelation ==="); // Step 1: Connect with GCP Exporters enabled via DataSource DataSource ds = DataSource.fromUrl(CONNECTION_URL); @@ -149,13 +142,9 @@ public void testExecute_withErrorCorrelation() throws Exception { BigQueryConnection bqConnection = connection.unwrap(BigQueryConnection.class); connectionUuid = bqConnection.getConnectionId(); assertNotNull(connectionUuid, "Connection UUID should be generated"); - System.out.println("[DEBUG_IT] Generated connectionUuid: " + connectionUuid); // Execute a query designed to fail instantly due to syntax error (compiler-level failure) assertThrows(SQLException.class, () -> statement.executeQuery("SELECT * FROM;")); - System.out.println( - "[DEBUG_IT] Expected SQLException caught. Waiting for logs and traces for connectionUuid: " - + connectionUuid); } // Step 2: Retrieve and assert logs, harvesting the TraceId @@ -180,7 +169,6 @@ public void testExecute_withErrorCorrelation() throws Exception { @Test public void testExecute_withCustomCredentialsJson() throws Exception { - System.out.println("[DEBUG_IT] === Starting testExecute_withCustomCredentialsJson ==="); JsonObject authJson = getAuthJson(); DataSource ds = DataSource.fromUrl(CONNECTION_URL); ds.setEnableGcpTraceExporter(true); @@ -192,7 +180,6 @@ public void testExecute_withCustomCredentialsJson() throws Exception { @Test public void testExecute_withCustomCredentialsFilePath() throws Exception { - System.out.println("[DEBUG_IT] === Starting testExecute_withCustomCredentialsFilePath ==="); JsonObject authJson = getAuthJson(); File tempFile = File.createTempFile("auth", ".json"); tempFile.deleteOnExit(); @@ -208,7 +195,6 @@ public void testExecute_withCustomCredentialsFilePath() throws Exception { @Test public void testExecute_withHttpProtocol() throws Exception { - System.out.println("[DEBUG_IT] === Starting testExecute_withHttpProtocol ==="); JsonObject authJson = getAuthJson(); System.setProperty("otel.exporter.otlp.protocol", "http/protobuf"); @@ -226,7 +212,6 @@ public void testExecute_withHttpProtocol() throws Exception { @Test public void testExecute_withGrpcProtocol() throws Exception { - System.out.println("[DEBUG_IT] === Starting testExecute_withGrpcProtocol ==="); JsonObject authJson = getAuthJson(); System.setProperty("otel.exporter.otlp.protocol", "grpc"); @@ -252,7 +237,6 @@ private void verifyTraceDelivery(DataSource ds) throws Exception { BigQueryConnection bqConnection = connection.unwrap(BigQueryConnection.class); connectionUuid = bqConnection.getConnectionId(); - System.out.println("[DEBUG_IT] verifyTraceDelivery connectionUuid: " + connectionUuid); String query = "SELECT 1;"; try (ResultSet rs = statement.executeQuery(query)) { @@ -321,95 +305,46 @@ private Trace verifyAndFetchTrace(String traceId) throws Exception { } } - private T pollWithRetry(String taskDescription, java.util.concurrent.Callable task) - throws InterruptedException { + private T pollWithRetry(java.util.concurrent.Callable task) throws InterruptedException { int attempts = 0; int maxAttempts = 24; long delayMs = 10000; - System.out.println( - "[DEBUG_IT] [" - + taskDescription - + "] Starting polling (maxAttempts=" - + maxAttempts - + ", delayMs=" - + delayMs - + "). Waiting 10 seconds initially..."); // 10 second wait for GCP to ingest data Thread.sleep(10000); while (attempts < maxAttempts) { attempts++; - System.out.println( - "[DEBUG_IT] [" + taskDescription + "] Attempt " + attempts + "/" + maxAttempts); try { T result = task.call(); if (result != null) { - System.out.println( - "[DEBUG_IT] [" - + taskDescription - + "] Succeeded on attempt " - + attempts - + "/" - + maxAttempts); return result; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException("Test execution interrupted", e); } catch (Exception e) { - System.err.println( - "[DEBUG_IT] [" - + taskDescription - + "] Exception on attempt " - + attempts - + ": " - + e.getClass().getName() - + " - " - + e.getMessage()); + // Ignore exceptions during remote lookup and retry e.printStackTrace(); } if (attempts < maxAttempts) { Thread.sleep(delayMs); } } - System.err.println( - "[DEBUG_IT] [" + taskDescription + "] Timed out after " + maxAttempts + " attempts."); return null; } private List fetchLogsWithRetry(Logging logging, String filter) throws InterruptedException { - System.out.println("[DEBUG_IT] Polling GCP Cloud Logging with filter: " + filter); List result = pollWithRetry( - "fetchLogsWithRetry (" + filter + ")", () -> { Page entriesPage = logging.listLogEntries( Logging.EntryListOption.filter(filter), Logging.EntryListOption.pageSize(50)); List entries = new ArrayList<>(); entriesPage.iterateAll().forEach(entries::add); - if (entries.isEmpty()) { - System.out.println("[DEBUG_IT] -> Found 0 matching log entries."); - return null; - } - System.out.println( - "[DEBUG_IT] -> Found " + entries.size() + " matching log entries:"); - for (LogEntry entry : entries) { - System.out.println( - "[DEBUG_IT] LogEntry: logName=" - + entry.getLogName() - + ", trace=" - + entry.getTrace() - + ", spanId=" - + entry.getSpanId() - + ", labels=" - + entry.getLabels() - + ", payload=" - + entry.getPayload()); - } - return entries; + return entries.isEmpty() ? null : entries; }); return result != null ? result : new ArrayList<>(); } @@ -417,36 +352,17 @@ private List fetchLogsWithRetry(Logging logging, String filter) private Trace fetchTraceWithRetry( TraceServiceClient traceClient, String projectId, String traceId) throws InterruptedException { - System.out.println( - "[DEBUG_IT] Polling GCP Cloud Trace with projectId=" + projectId + ", traceId=" + traceId); return pollWithRetry( - "fetchTraceWithRetry (" + traceId + ")", () -> { Trace trace = traceClient.getTrace(projectId, traceId); if (trace == null) { - System.out.println("[DEBUG_IT] -> traceClient.getTrace returned null."); return null; } - System.out.println( - "[DEBUG_IT] -> Found trace with " + trace.getSpansCount() + " spans:"); - boolean foundExecuteQuery = false; for (TraceSpan span : trace.getSpansList()) { - System.out.println( - "[DEBUG_IT] Span: name=" - + span.getName() - + ", spanId=" - + span.getSpanId() - + ", parentSpanId=" - + span.getParentSpanId()); if (span.getName().equals("BigQueryStatement.executeQuery")) { - foundExecuteQuery = true; + return trace; } } - if (foundExecuteQuery) { - return trace; - } - System.out.println( - "[DEBUG_IT] -> Trace present, but 'BigQueryStatement.executeQuery' span not yet found."); return null; }); } From 13316ec570ea7f8180ca196ead426ce631436536 Mon Sep 17 00:00:00 2001 From: Keshav Dandeva Date: Tue, 4 Aug 2026 20:44:27 +0000 Subject: [PATCH 5/5] address pr feedback and revert ipv4 changes --- java-bigquery-jdbc/pom.xml | 7 ++----- .../cloud/bigquery/jdbc/OpenTelemetryJulHandler.java | 12 ++++-------- .../cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java | 4 ++-- .../cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java | 2 +- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/java-bigquery-jdbc/pom.xml b/java-bigquery-jdbc/pom.xml index c3b049c596e4..24bd9b89eec9 100644 --- a/java-bigquery-jdbc/pom.xml +++ b/java-bigquery-jdbc/pom.xml @@ -32,7 +32,6 @@ github google-cloud-bigquery-jdbc false - -Djava.net.preferIPv4Stack=true @@ -48,7 +47,6 @@ maven-surefire-plugin 3.5.2 - @{argLine} ${preferIpv4.test.argLine} ${skipSurefire} true @@ -59,7 +57,6 @@ org.apache.maven.plugins maven-failsafe-plugin - @{argLine} ${preferIpv4.test.argLine} true @@ -480,14 +477,14 @@ org.apache.maven.plugins maven-surefire-plugin - @{argLine} ${preferIpv4.test.argLine} --add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED + --add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED org.apache.maven.plugins maven-failsafe-plugin - @{argLine} ${preferIpv4.test.argLine} --add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED + --add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED diff --git a/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/OpenTelemetryJulHandler.java b/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/OpenTelemetryJulHandler.java index 0edd2b0300d8..79874f7d085a 100644 --- a/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/OpenTelemetryJulHandler.java +++ b/java-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/OpenTelemetryJulHandler.java @@ -30,6 +30,7 @@ import io.opentelemetry.context.Context; import java.time.Instant; import java.util.Collections; +import java.util.logging.ErrorManager; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -78,10 +79,8 @@ public void publish(LogRecord record) { publishToOTel(record, connectionId, config.openTelemetry); } } catch (Throwable t) { - reportError( - "Error publishing log to OpenTelemetry/GCP", - new Exception(t), - java.util.logging.ErrorManager.WRITE_FAILURE); + Exception ex = (t instanceof Exception) ? (Exception) t : new Exception(t); + reportError("Error publishing log to OpenTelemetry/GCP", ex, ErrorManager.WRITE_FAILURE); } } @@ -185,10 +184,7 @@ public void flush() { try { config.loggingClient.flush(); } catch (Exception e) { - reportError( - "Error flushing log to OpenTelemetry/GCP", - e, - java.util.logging.ErrorManager.FLUSH_FAILURE); + reportError("Error flushing log to OpenTelemetry/GCP", e, ErrorManager.FLUSH_FAILURE); } } } diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java index cae03f1a359a..aa44e64d7438 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITBigQueryJDBCTest.java @@ -36,6 +36,7 @@ import com.google.cloud.bigquery.jdbc.BigQueryConnection; import com.google.cloud.bigquery.jdbc.BigQueryDriver; import com.google.cloud.bigquery.jdbc.DataSource; +import com.google.cloud.bigquery.jdbc.OpenTelemetryJulHandler; import com.google.common.collect.ImmutableMap; import java.io.File; import java.io.IOException; @@ -2808,8 +2809,7 @@ public void testPerConnectionLoggingE2E() throws SQLException, IOException { java.util.logging.Logger bqLogger = java.util.logging.Logger.getLogger("com.google.cloud.bigquery"); for (java.util.logging.Handler h : bqLogger.getHandlers()) { - if (h instanceof java.util.logging.FileHandler - || h.getClass().getName().endsWith("PerConnectionFileHandler")) { + if (!(h instanceof OpenTelemetryJulHandler)) { h.close(); bqLogger.removeHandler(h); } diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java index 4ffb4c9aed1b..444b92fcefc0 100644 --- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java +++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java @@ -307,7 +307,7 @@ private Trace verifyAndFetchTrace(String traceId) throws Exception { private T pollWithRetry(java.util.concurrent.Callable task) throws InterruptedException { int attempts = 0; - int maxAttempts = 24; + int maxAttempts = 10; long delayMs = 10000; // 10 second wait for GCP to ingest data