Skip to content

Commit 6481bff

Browse files
committed
fix: split unit tests
1 parent 996b987 commit 6481bff

1 file changed

Lines changed: 24 additions & 20 deletions

File tree

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/OpenTelemetryJulHandler.java

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,33 @@ public void publish(LogRecord record) {
4848
return;
4949
}
5050

51-
// Extract connection ID from baggage
52-
String connectionId =
53-
Baggage.fromContext(Context.current()).getEntryValue("jdbc.connection_id");
54-
55-
// Fallback to MDC if not in baggage (if MDC is available and used)
56-
if (connectionId == null) {
57-
connectionId = BigQueryJdbcMdc.getConnectionId();
58-
}
51+
try {
52+
// Extract connection ID from baggage
53+
String connectionId =
54+
Baggage.fromContext(Context.current()).getEntryValue("jdbc.connection_id");
55+
56+
// Fallback to MDC if not in baggage (if MDC is available and used)
57+
if (connectionId == null) {
58+
connectionId = BigQueryJdbcMdc.getConnectionId();
59+
}
5960

60-
if (connectionId == null) {
61-
return;
62-
}
61+
if (connectionId == null) {
62+
return;
63+
}
6364

64-
BigQueryJdbcOpenTelemetry.TelemetryConfig config =
65-
BigQueryJdbcOpenTelemetry.getConnectionConfig(connectionId);
66-
if (config == null) {
67-
return;
68-
}
65+
BigQueryJdbcOpenTelemetry.TelemetryConfig config =
66+
BigQueryJdbcOpenTelemetry.getConnectionConfig(connectionId);
67+
if (config == null) {
68+
return;
69+
}
6970

70-
if (config.useDirectGcpLogging && config.loggingClient != null) {
71-
publishToGcp(record, connectionId, config.loggingClient);
72-
} else if (config.openTelemetry != null) {
73-
publishToOTel(record, connectionId, config.openTelemetry);
71+
if (config.useDirectGcpLogging && config.loggingClient != null) {
72+
publishToGcp(record, connectionId, config.loggingClient);
73+
} else if (config.openTelemetry != null) {
74+
publishToOTel(record, connectionId, config.openTelemetry);
75+
}
76+
} catch (Throwable t) {
77+
// Ignore exceptions to prevent breaking application logging or other handlers
7478
}
7579
}
7680

0 commit comments

Comments
 (0)