Repository navigation
fix(bigquery-jdbc): propagate proxy and SSLTrustStore to OpenTelemetry trace exporter - #15344
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for SSL trust store configuration and refactors proxy handling within the OpenTelemetry telemetry client. It propagates SSL trust store properties to HTTP and gRPC span exporters and enforces the HTTP protobuf protocol when a proxy is used with the GCP trace exporter. A review comment correctly identifies a regression in createProxyOptions where defensive checks and robust exception handling for parsing the proxy port were removed, which could lead to unhandled exceptions. This error handling should be restored.
| private static ProxyOptions createProxyOptions(Map<String, String> proxyProperties) { | ||
| if (proxyProperties == null) { | ||
| return null; | ||
| } | ||
|
|
||
| final String host = proxyProperties.get(BigQueryJdbcUrlUtility.PROXY_HOST_PROPERTY_NAME); | ||
| final String portStr = proxyProperties.get(BigQueryJdbcUrlUtility.PROXY_PORT_PROPERTY_NAME); | ||
| if (host == null || host.isEmpty() || portStr == null || portStr.isEmpty()) { | ||
| return null; | ||
| } | ||
|
|
||
| int port; | ||
| try { | ||
| port = Integer.parseInt(portStr); | ||
| } catch (NumberFormatException e) { | ||
| throw new BigQueryJdbcRuntimeException("Invalid proxy port number: " + portStr, e); | ||
| } | ||
|
|
||
| String host = proxyProperties.get(BigQueryJdbcUrlUtility.PROXY_HOST_PROPERTY_NAME); | ||
| int port = | ||
| Integer.parseInt(proxyProperties.get(BigQueryJdbcUrlUtility.PROXY_PORT_PROPERTY_NAME)); | ||
| return ProxyOptions.create(InetSocketAddress.createUnresolved(host, port)); | ||
| } |
There was a problem hiding this comment.
The previous implementation of createProxyOptions safely handled missing or invalid proxy host/port configurations by returning null or throwing a descriptive BigQueryJdbcRuntimeException with a clear error message. The new implementation removes these guards and the try-catch block, which can lead to raw NumberFormatExceptions or NullPointerExceptions if the proxy properties are malformed or incomplete.
We should restore the defensive checks and wrap any NumberFormatException in a BigQueryJdbcRuntimeException to maintain robust error handling and clear diagnostics.
private static ProxyOptions createProxyOptions(Map<String, String> proxyProperties) {
String host = proxyProperties.get(BigQueryJdbcUrlUtility.PROXY_HOST_PROPERTY_NAME);
String portStr = proxyProperties.get(BigQueryJdbcUrlUtility.PROXY_PORT_PROPERTY_NAME);
if (host == null || host.isEmpty() || portStr == null || portStr.isEmpty()) {
throw new BigQueryJdbcRuntimeException("Proxy host and port must be specified");
}
int port;
try {
port = Integer.parseInt(portStr);
} catch (NumberFormatException e) {
throw new BigQueryJdbcRuntimeException("Invalid proxy port number: " + portStr, e);
}
return ProxyOptions.create(InetSocketAddress.createUnresolved(host, port));
}
Summary
Propagates
ProxyHost/ProxyPortandSSLTrustStore*settings fromBigQueryConnectioninto the built-in OpenTelemetry trace exporters without adding new dependencies or custom HTTP senders.Key Decisions
ProxyOptionsandsetSslContext: ReusesBigQueryJdbcProxyUtility.createSslConfig(...)(JDK default TLS provider, avoiding Java 8 Conscrypt/OkHttp ALPN issues) on bothOtlpGrpcSpanExporterBuilderandOtlpHttpSpanExporterBuilder.http/protobufwhen proxied: OpenTelemetry Java1.67.0supportsProxyOptionsonOtlpHttpSpanExporterBuilder(not gRPC), so when an unauthenticated proxy is configured andenableGcpTraceExporter=true, the driver setsotel.exporter.otlp.protocolandotel.exporter.otlp.traces.protocoltohttp/protobufviaaddPropertiesCustomizer(...)while preserving user headers, compression, timeouts, and non-OTLP exporters.ProxyUid/ProxyPwd): Because OpenTelemetry Java1.67.0'sProxyOptionsdoes not support proxy authentication, we rejectenableGcpTraceExporter=true+ProxyUid/ProxyPwdeagerly rather than silently exporting directly or maintaining a custom OTLP HTTP sender. Callers can disableenableGcpTraceExporteror pass a preconfigured instance viaDataSource.setCustomOpenTelemetry(...). Support for authenticated proxies in built-in trace export will be tracked separately.Behavior Changes
ProxyHost/ProxyPortoverhttp/protobufand trusts certificates fromSSLTrustStore*over both OTLP HTTP and gRPC.enableGcpTraceExporter=truewithProxyUid/ProxyPwdnow fail at connection setup withBigQueryJdbcRuntimeException.enableGcpLogExporter=trueand custom/globalOpenTelemetryinstances are unaffected.