Skip to content

fix(bigquery-jdbc): propagate universeDomain and overrides to OpenTelemetry trace export - #15343

Open
keshavdandeva wants to merge 3 commits into
fix/jdbc-telemetry-1-proxy-ssl-utilsfrom
fix/jdbc-telemetry-2-otel-universe-domain
Open

keshavdandeva wants to merge 3 commits into
fix/jdbc-telemetry-1-proxy-ssl-utilsfrom
fix/jdbc-telemetry-2-otel-universe-domain

Conversation

@keshavdandeva

Copy link
Copy Markdown
Contributor

Summary

Propagates connection-level universeDomain, EndpointOverrides (OAUTH2), and HTTP transport settings into OpenTelemetry trace export and telemetry credential loading, consistent with #15211.

Key Decisions

  • Introduced TelemetryTransportConfig: Package-private config carrier passed from BigQueryConnection.getOpenTelemetryInstance() to BigQueryJdbcOpenTelemetry.getOpenTelemetry(...), replacing the raw proxyProperties map with universeDomain, overrideProperties, proxyProperties, and httpTransportFactory.
  • Telemetry-scoped hostname validation: Multi-label DNS validation (validateNormalizedUniverseDomain, max length 243 so telemetry.<universeDomain> fits within 253 chars) lives in BigQueryJdbcOpenTelemetry rather than DataSource/BigQueryJdbcUrlUtility to preserve backward compatibility with non-telemetry tests and callers using single-label domains.
  • Eager credential/universe validation without GCE metadata probes: resolveTelemetryCredentials(...) validates credentials.getUniverseDomain() against the resolved target universe domain before creating exporters, iteratively unwrapping ImpersonatedCredentials and skipping ComputeEngineCredentials to avoid live metadata server calls.
  • Preserved createScopedRequired() check: Matches existing driver and Google Cloud Java SDK convention so pre-scoped ServiceAccountCredentials do not have caller-restricted scopes overwritten.

Behavior Changes

  • Dynamic OTLP endpoint: Built-in trace export now targets https://telemetry.<universeDomain>:443 instead of hardcoded https://telemetry.googleapis.com:443.
  • Credential loading with overrides and transport: resolveCredentialsFromString(...) forwards overrideProperties (OAUTH2 token URI and explicit universeDomain overrides, preserving JSON-embedded universe_domain per #15211) and httpTransportFactory into BigQueryJdbcOAuthUtility.getCredentials(...).
  • Eager failure on misconfiguration: Invalid universeDomain, unresolvable gcpTelemetryCredentials, or a mismatch between credential and target universeDomain now fail at connection setup with BigQueryJdbcRuntimeException instead of exporting unauthenticated or to the wrong endpoint.

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

@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 introduces a TelemetryTransportConfig class to encapsulate telemetry transport configurations (such as universe domain, override properties, proxy properties, and HTTP transport factory) and propagates it from BigQueryConnection to BigQueryJdbcOpenTelemetry. It also adds validation for the universe domain, credentials matching, and updates span exporter customization, backed by comprehensive unit tests. The review feedback suggests adding a null check for httpTransportOptions to prevent a potential NullPointerException and making defensive copies of the configuration maps to ensure thread safety and prevent external modification.

.setUniverseDomain(this.universeDomain)
.setOverrideProperties(this.overrideProperties)
.setProxyProperties(this.proxyProperties)
.setHttpTransportFactory(this.httpTransportOptions.getHttpTransportFactory())

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

To prevent a potential NullPointerException, check if this.httpTransportOptions is null before calling getHttpTransportFactory().

Suggested change
.setHttpTransportFactory(this.httpTransportOptions.getHttpTransportFactory())
.setHttpTransportFactory(this.httpTransportOptions != null ? this.httpTransportOptions.getHttpTransportFactory() : null)

Comment on lines +114 to +117
this.overrideProperties =
builder.overrideProperties != null ? builder.overrideProperties : Collections.emptyMap();
this.proxyProperties =
builder.proxyProperties != null ? builder.proxyProperties : Collections.emptyMap();

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

To prevent external modification of the configuration maps and ensure thread safety, it is recommended to make defensive copies of the overrideProperties and proxyProperties maps and wrap them in an unmodifiable map.

Suggested change
this.overrideProperties =
builder.overrideProperties != null ? builder.overrideProperties : Collections.emptyMap();
this.proxyProperties =
builder.proxyProperties != null ? builder.proxyProperties : Collections.emptyMap();
this.overrideProperties = builder.overrideProperties != null ? Collections.unmodifiableMap(new HashMap<>(builder.overrideProperties)) : Collections.emptyMap();
this.proxyProperties = builder.proxyProperties != null ? Collections.unmodifiableMap(new HashMap<>(builder.proxyProperties)) : Collections.emptyMap();

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