Skip to content

feat(bigquery-jdbc): add globalOtel support#13282

Merged
keshavdandeva merged 4 commits into
jdbc/e2e-test-otelfrom
jdbc/enable-global-otel
May 28, 2026
Merged

feat(bigquery-jdbc): add globalOtel support#13282
keshavdandeva merged 4 commits into
jdbc/e2e-test-otelfrom
jdbc/enable-global-otel

Conversation

@keshavdandeva
Copy link
Copy Markdown
Contributor

b/517124136

This PR introduces support for opting into the global OpenTelemetry instance via connection properties in the BigQuery JDBC driver. It also establishes a clear hierarchy of precedence for various OpenTelemetry configuration flags to ensure predictable behavior

Key Changes

1. Global OpenTelemetry Support

  • Added a new connection property useGlobalOpenTelemetry (default: false).
  • When set to true, the driver will explicitly use the globally registered OpenTelemetry instance (GlobalOpenTelemetry.get()) for both tracing and logging.

2. Precedence Rules for Telemetry Flags

Implemented the following hierarchy of precedence in BigQueryConnection:

  1. customOpenTelemetry (Provided via DataSource): Highest precedence. Overrides everything else.
  2. useGlobalOpenTelemetry: Second precedence. Overrides driver-managed GCP fallback flags.
  3. enableGcpTraceExporter / enableGcpLogExporter: Lowest precedence. Used only if above are false/null.

3. Code Modifications

  • BigQueryJdbcUrlUtility.java: Added property definition and added it to valid properties.
  • DataSource.java: Added field, getter/setter, and URL parsing support for the new property.
  • BigQueryConnection.java: Updated constructor to read the new property and implemented the precedence logic for both tracer initialization and logging client registration.
  • BigQueryJdbcOpenTelemetry.java: Updated getOpenTelemetry() to handle the useGlobalOpenTelemetry flag.

4. Testing

  • BigQueryJdbcOpenTelemetryTest.java: Added unit test to verify that useGlobalOpenTelemetry returns the global instance.
  • BigQueryConnectionTest.java: Added a comprehensive parameterized test (testOpenTelemetryPrecedenceHierarchy) covering all 8 combinations of the 4 flags to verify the correct behavior of OpenTelemetry resolution and logging client creation.

@keshavdandeva keshavdandeva requested a review from a team as a code owner May 27, 2026 17:37
Copy link
Copy Markdown
Contributor

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

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 new configuration option, useGlobalOpenTelemetry, allowing the BigQuery JDBC driver to utilize the global OpenTelemetry instance. The changes integrate this option across the connection, data source, and utility classes, and add comprehensive unit tests to verify the precedence hierarchy of OpenTelemetry configurations. The review feedback highlights an unused variable hasCustomOtel left in BigQueryConnection and suggests stubbing getTracer on the mocked OpenTelemetry instances in the new tests to prevent potential NullPointerExceptions.

@keshavdandeva
Copy link
Copy Markdown
Contributor Author

/gemini review

@keshavdandeva keshavdandeva requested a review from logachev May 27, 2026 17:49
Copy link
Copy Markdown
Contributor

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

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 support for using the global OpenTelemetry instance in the BigQuery JDBC driver. It adds a new configuration property useGlobalOpenTelemetry to the connection properties, data source, and connection logic, allowing the driver to fall back to GlobalOpenTelemetry.get() when enabled. Additionally, comprehensive unit tests have been added to verify the precedence hierarchy of OpenTelemetry configurations. One review comment suggests wrapping the BigQueryConnection in a try-with-resources block within the new test to ensure exception-safe resource cleanup and prevent potential resource leaks.

@keshavdandeva keshavdandeva merged commit 6229229 into jdbc/e2e-test-otel May 28, 2026
131 of 134 checks passed
@keshavdandeva keshavdandeva deleted the jdbc/enable-global-otel branch May 28, 2026 14:19
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