Skip to content

feat(bigquery-jdbc): add TelemetryManager singleton foundation and exception safeguards - #14048

Open
Neenu1995 wants to merge 3 commits into
jdbc-telemetry-featurefrom
jdbc-telemetry-pr7-manager-core
Open

feat(bigquery-jdbc): add TelemetryManager singleton foundation and exception safeguards#14048
Neenu1995 wants to merge 3 commits into
jdbc-telemetry-featurefrom
jdbc-telemetry-pr7-manager-core

Conversation

@Neenu1995

@Neenu1995 Neenu1995 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Introduces the internal package-private TelemetryManager singleton hub for PR 7 of the client-side diagnostic telemetry client implementation (b/527947900).

  • Singleton Lifecycle: Implements thread-safe double-checked locking (volatile) for zero-contention fast-path telemetry checks (getInstance(), init(), closeInstance()).
  • Driver Stability Safeguard: Adds exception-isolation wrapper runSafely(Runnable) ensuring telemetry operations never throw or block driver connection/query hotpaths.
  • Unit Testing: Adds TelemetryManagerTest covering singleton initialization contract, double-checked locking, custom configuration overrides, and zero-exception bubbling.

@Neenu1995
Neenu1995 requested review from a team as code owners August 11, 2026 22:22

@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 thread-safe singleton, TelemetryManager, to manage the lifecycle of client-side diagnostic and usage telemetry in the BigQuery JDBC driver, along with corresponding unit tests and minor .gitignore updates. The review feedback suggests improving the singleton's lifecycle management by introducing a DISABLED_INSTANCE sentinel. This sentinel prevents re-initialization with default settings when telemetry is explicitly disabled, and the feedback includes specific suggestions to update getInstance(), init(), isInitialized(), and closeInstance() to handle this sentinel state correctly.

@Neenu1995
Neenu1995 requested review from a team as code owners August 12, 2026 15:31
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@Neenu1995
Neenu1995 force-pushed the jdbc-telemetry-pr7-manager-core branch from ee6ed51 to a8ff62d Compare August 12, 2026 23:00
@Neenu1995
Neenu1995 force-pushed the jdbc-telemetry-pr7-manager-core branch from a8ff62d to c69b696 Compare August 12, 2026 23:11
tools/**/drivers/**
tools/**/logs/**
tools/**/*.jfr
tools/**/odbc/

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.

Can this be removed?

*/
static TelemetryManager getInstance() {
TelemetryManager localRef = instance;
if (localRef == null) {

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.

nit: should we use isInitilized?


public class TelemetryManagerTest {

@BeforeEach

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.

Why do we need additional cleanup before the test?

() -> {
throw new RuntimeException("Simulated telemetry exception");
});
lineAfterException.set(true);

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.

nit: You don't need this. If it raised an exception, test will fail either way.

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