Skip to content

Commit 1bbc240

Browse files
committed
pr feedback
1 parent d1656a4 commit 1bbc240

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
3535
import io.opentelemetry.sdk.OpenTelemetrySdk;
3636
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
37-
import java.io.IOException;
3837
import java.net.URI;
3938
import java.nio.charset.StandardCharsets;
4039
import java.sql.SQLException;
@@ -67,6 +66,7 @@ public class BigQueryJdbcOpenTelemetry {
6766
private static final String OTEL_METRICS_EXPORTER = "otel.metrics.exporter";
6867
private static final String GOOGLE_CLOUD_PROJECT = "google.cloud.project";
6968
private static final String OTLP_ENDPOINT_VALUE = "https://telemetry.googleapis.com:443";
69+
private static final URI OTLP_ENDPOINT_URI = URI.create(OTLP_ENDPOINT_VALUE);
7070
private static final String EXPORTER_NONE = "none";
7171
private static final String EXPORTER_OTLP = "otlp";
7272
private static final String OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT =
@@ -235,8 +235,7 @@ public static Collection<TelemetryConfig> getRegisteredConfigs() {
235235

236236
private static Map<String, String> getAuthHeaders(Credentials credentials) {
237237
try {
238-
Map<String, List<String>> metadata =
239-
credentials.getRequestMetadata(URI.create(OTLP_ENDPOINT_VALUE));
238+
Map<String, List<String>> metadata = credentials.getRequestMetadata(OTLP_ENDPOINT_URI);
240239
Map<String, String> headers = new HashMap<>();
241240
metadata.forEach(
242241
(headerKey, headerValues) -> {
@@ -245,7 +244,7 @@ private static Map<String, String> getAuthHeaders(Credentials credentials) {
245244
}
246245
});
247246
return headers;
248-
} catch (IOException e) {
247+
} catch (Exception e) {
249248
// We log the warning and return an empty map, allowing the exporter to fail gracefully
250249
// with a standard OTLP response code (e.g., 401 Unauthorized) handled by OTel.
251250
LOG.warning(e, "Failed to get auth headers");

0 commit comments

Comments
 (0)