Repository navigation
fix(bigquery-jdbc): propagate universeDomain and overrides to OpenTelemetry trace export - #15343
keshavdandeva wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
To prevent a potential NullPointerException, check if this.httpTransportOptions is null before calling getHttpTransportFactory().
| .setHttpTransportFactory(this.httpTransportOptions.getHttpTransportFactory()) | |
| .setHttpTransportFactory(this.httpTransportOptions != null ? this.httpTransportOptions.getHttpTransportFactory() : null) |
| this.overrideProperties = | ||
| builder.overrideProperties != null ? builder.overrideProperties : Collections.emptyMap(); | ||
| this.proxyProperties = | ||
| builder.proxyProperties != null ? builder.proxyProperties : Collections.emptyMap(); |
There was a problem hiding this comment.
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.
| 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(); |
Summary
Propagates connection-level
universeDomain,EndpointOverrides(OAUTH2), and HTTP transport settings into OpenTelemetry trace export and telemetry credential loading, consistent with#15211.Key Decisions
TelemetryTransportConfig: Package-private config carrier passed fromBigQueryConnection.getOpenTelemetryInstance()toBigQueryJdbcOpenTelemetry.getOpenTelemetry(...), replacing the rawproxyPropertiesmap withuniverseDomain,overrideProperties,proxyProperties, andhttpTransportFactory.validateNormalizedUniverseDomain, max length243sotelemetry.<universeDomain>fits within 253 chars) lives inBigQueryJdbcOpenTelemetryrather thanDataSource/BigQueryJdbcUrlUtilityto preserve backward compatibility with non-telemetry tests and callers using single-label domains.resolveTelemetryCredentials(...)validatescredentials.getUniverseDomain()against the resolved target universe domain before creating exporters, iteratively unwrappingImpersonatedCredentialsand skippingComputeEngineCredentialsto avoid live metadata server calls.createScopedRequired()check: Matches existing driver and Google Cloud Java SDK convention so pre-scopedServiceAccountCredentialsdo not have caller-restricted scopes overwritten.Behavior Changes
https://telemetry.<universeDomain>:443instead of hardcodedhttps://telemetry.googleapis.com:443.resolveCredentialsFromString(...)forwardsoverrideProperties(OAUTH2token URI and explicituniverseDomainoverrides, preserving JSON-embeddeduniverse_domainper#15211) andhttpTransportFactoryintoBigQueryJdbcOAuthUtility.getCredentials(...).universeDomain, unresolvablegcpTelemetryCredentials, or a mismatch between credential and targetuniverseDomainnow fail at connection setup withBigQueryJdbcRuntimeExceptioninstead of exporting unauthenticated or to the wrong endpoint.