Skip to content

fix(bigquery-jdbc): suppress Clearcut diagnostic telemetry for custom universes and endpoint overrides - #15395

Open
keshavdandeva wants to merge 13 commits into
fix/jdbc-clearcut-lifecycle-optoutfrom
fix/jdbc-clearcut-realm-suppression
Open

keshavdandeva wants to merge 13 commits into
fix/jdbc-clearcut-lifecycle-optoutfrom
fix/jdbc-clearcut-realm-suppression

Conversation

@keshavdandeva

@keshavdandeva keshavdandeva commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #15394.

Summary

Suppresses Clearcut diagnostic telemetry whenever a connection targets a non-default universe domain, custom endpoint override, or Private Service Connect URI, and moves telemetry initialization to BigQueryConnection after credentials are resolved.

Key changes

  • BigQueryJdbcDiagnosticTelemetry: Evaluates suppression (EndpointOverrides, PrivateServiceConnectUris, resolved universeDomain / GOOGLE_CLOUD_UNIVERSE_DOMAIN, and credential universe domain) and opt-out rules for both established connections and BigQueryDriver.connect failures.
  • BigQueryConnection & BigQueryDriver: Replaces early TelemetryManager.getInstance(...) initialization in BigQueryDriver.connect with BigQueryJdbcDiagnosticTelemetry.initializeOrDisable(...) right after credential resolution in BigQueryConnection, and routes connection failures through BigQueryJdbcDiagnosticTelemetry.recordFailedConnection(...).
  • BigQueryJdbcUrlUtility: Adds parseLastUriPropertyWithoutValidation so raw URI fallback parsing on failed connects uses last-wins semantics matching parseUrl.
  • TelemetryManager & TelemetryConfiguration: Adds typed @InternalApi entry points (initializeForConnection(Boolean), disableGlobally(String)) and resolveEnabled(Boolean) so eligibility checks do not round-trip booleans through Properties.
  • Tests: Adds unit and driver-level coverage for suppression across URL, DataSource, environment variables, credential universes, and failed connections, and ensures telemetry state is reset in test teardown.

Decisions made

  • Post-credential initialization: Deferring initialization until after BigQueryJdbcOAuthUtility.getCredentials(...) ensures credential-declared universe domains are evaluated before any Clearcut transport starts.
  • No metadata lookup on GCE credentials: Skips credentials.getUniverseDomain() for ComputeEngineCredentials (including ImpersonatedCredentials chains backed by GCE) to avoid blocking on the metadata server; explicit universeDomain and GOOGLE_CLOUD_UNIVERSE_DOMAIN overrides still apply.
  • Last-wins raw URI fallback: Failed connects before DataSource.fromUrl inspect the raw URI with last-wins semantics and fail closed if EnableDiagnosticTelemetry is malformed.
  • JVM-wide non-flushing disable: Because TelemetryManager is a process-wide singleton shared across connections, any suppressed or opted-out connection disables telemetry for the JVM without flushing queued events.

@keshavdandeva
keshavdandeva requested review from a team as code owners December 2, 2026 18:16

@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 the BigQueryJdbcDiagnosticTelemetry class to coordinate Clearcut diagnostic telemetry eligibility and lifecycle transitions for BigQuery JDBC connections. It refactors BigQueryConnection and BigQueryDriver to delegate telemetry initialization, suppression checks, and failed connection recording to this new coordinator. Additionally, it updates TelemetryManager and TelemetryConfiguration to support explicit boolean overrides and adds comprehensive unit tests to validate telemetry suppression rules under various configurations. There are no review comments, so I have no feedback to provide.

@logachev logachev 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.

It will conflict with changes to URI parsing. Let's wait for another PR to be merged first, it will require changes.

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.

2 participants