3434import io .opentelemetry .exporter .otlp .trace .OtlpGrpcSpanExporter ;
3535import io .opentelemetry .sdk .OpenTelemetrySdk ;
3636import io .opentelemetry .sdk .autoconfigure .AutoConfiguredOpenTelemetrySdk ;
37- import java .io .IOException ;
3837import java .net .URI ;
3938import java .nio .charset .StandardCharsets ;
4039import 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