Skip to content

fix(bigquery-jdbc): propagate proxy and SSLTrustStore to OpenTelemetry trace exporter - #15344

Open
keshavdandeva wants to merge 3 commits into
fix/jdbc-telemetry-2-otel-universe-domainfrom
fix/jdbc-telemetry-3-otel-proxy-truststore
Open

keshavdandeva wants to merge 3 commits into
fix/jdbc-telemetry-2-otel-universe-domainfrom
fix/jdbc-telemetry-3-otel-proxy-truststore

Conversation

@keshavdandeva

Copy link
Copy Markdown
Contributor

Summary

Propagates ProxyHost/ProxyPort and SSLTrustStore* settings from BigQueryConnection into the built-in OpenTelemetry trace exporters without adding new dependencies or custom HTTP senders.

Key Decisions

  • Use OpenTelemetry's native ProxyOptions and setSslContext: Reuses BigQueryJdbcProxyUtility.createSslConfig(...) (JDK default TLS provider, avoiding Java 8 Conscrypt/OkHttp ALPN issues) on both OtlpGrpcSpanExporterBuilder and OtlpHttpSpanExporterBuilder.
  • Force http/protobuf when proxied: OpenTelemetry Java 1.67.0 supports ProxyOptions on OtlpHttpSpanExporterBuilder (not gRPC), so when an unauthenticated proxy is configured and enableGcpTraceExporter=true, the driver sets otel.exporter.otlp.protocol and otel.exporter.otlp.traces.protocol to http/protobuf via addPropertiesCustomizer(...) while preserving user headers, compression, timeouts, and non-OTLP exporters.
  • Fail closed on authenticated proxies (ProxyUid/ProxyPwd): Because OpenTelemetry Java 1.67.0's ProxyOptions does not support proxy authentication, we reject enableGcpTraceExporter=true + ProxyUid/ProxyPwd eagerly rather than silently exporting directly or maintaining a custom OTLP HTTP sender. Callers can disable enableGcpTraceExporter or pass a preconfigured instance via DataSource.setCustomOpenTelemetry(...). Support for authenticated proxies in built-in trace export will be tracked separately.

Behavior Changes

  • Unauthenticated proxy & TrustStore propagation: Built-in OTLP trace export now routes through ProxyHost/ProxyPort over http/protobuf and trusts certificates from SSLTrustStore* over both OTLP HTTP and gRPC.
  • Eager failure with authenticated proxies: Connections combining enableGcpTraceExporter=true with ProxyUid/ProxyPwd now fail at connection setup with BigQueryJdbcRuntimeException. enableGcpLogExporter=true and custom/global OpenTelemetry instances are unaffected.

@keshavdandeva
keshavdandeva requested review from a team as code owners December 1, 2026 18:30

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 786 to 791
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));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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));
  }

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant