Skip to content

test(bqjdbc): add e2e otel test and code refinements#13226

Open
keshavdandeva wants to merge 5 commits into
jdbc/feature-branch-otelfrom
jdbc/e2e-test-otel
Open

test(bqjdbc): add e2e otel test and code refinements#13226
keshavdandeva wants to merge 5 commits into
jdbc/feature-branch-otelfrom
jdbc/e2e-test-otel

Conversation

@keshavdandeva
Copy link
Copy Markdown
Contributor

b/499079838

Changes

1. BigQueryJdbcOpenTelemetry.java

  • Feature: Added safe, generous default attribute value length limits of 60KB (61,440 characters) to the autoconfigured OpenTelemetry instance properties.
  • Why: Prevents GCP Cloud Trace from silently rejecting and dropping span batches when we log massive BigQueryException stack traces or Arrow schema payloads exceeding the hard 64KB Cloud Trace backend limits.
  • Design: If the user explicitly configures their own limits the driver automatically skips the defaults and respects their overrides.

2. OpenTelemetryJulHandler.java

  • Fix: Configured the handler level to Level.ALL in the constructor.
  • Why: Bypasses a standard Java Logging (JUL) constraint where handlers default to Level.INFO and silently drop FINE/DEBUG queries. Delegates log filtering exclusively to the Connection loggers.

3. BigQueryConnection.java

  • Visibility: Exposed the visibility of the connection session identifier by changing getConnectionId() from package-private to public.
  • Why: Allows automated E2E tests to retrieve the UUID and harvest specific logs/traces accurately.

4. ITOpenTelemetryTest.java

  • Feature: Implemented a new standalone E2E integration test suite verifying the live GCP OTel egress.
  • Test 1 (testExecute_withOpenTelemetryGcpExporter): Natively resolves target project via ServiceOptions.getDefaultProjectId(). Runs an optimized in-memory array query and iterates results to trigger small-page JSON pagination. Queries Cloud Trace E2E to strictly assert that async pagination child spans are parented perfectly under the root JDBC span.
  • Test 2 (testExecute_withErrorCorrelation): Triggers database failures, captures SQLException, harvests Trace IDs from standard logs, and verifies failed span ingestion in Cloud Trace.

5. BigQueryConnectionTest.java

  • Feature: Added a new unit test (testConnect_withCustomOpenTelemetry_usesCustomInstance) verifying the custom OTel injection pipeline.
  • What it does: Leverages OpenTelemetryExtension to mock an OTel provider locally. Injecting the custom SDK via properties, it validates that BigQueryConnection resolves the instance and routes spans exclusively to the custom provider

6. pom.xml

  • Dependencies: Added google-cloud-trace test-scoped dependency to query Cloud Trace v1 API programmatically during E2E validation.

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 default limits (60KB) for OpenTelemetry attribute values to prevent ingestion failures in GCP Cloud Trace. It also exposes the connection ID, configures the JUL handler to capture all log levels, and adds comprehensive unit and integration tests for OpenTelemetry integration. Feedback focuses on improving the new integration test by switching from JUnit 4 to JUnit 5 for consistency and adhering to standard naming conventions for static constants.

Base automatically changed from jdbc/complete-otel-intrumentation to jdbc/feature-branch-otel May 19, 2026 12:43
@keshavdandeva keshavdandeva changed the base branch from jdbc/feature-branch-otel to main May 19, 2026 12:45
@keshavdandeva keshavdandeva changed the base branch from main to jdbc/feature-branch-otel May 19, 2026 12:45
@keshavdandeva
Copy link
Copy Markdown
Contributor Author

/gemini review

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 OpenTelemetry support for the BigQuery JDBC driver, including GCP exporters for traces and logs, and adds comprehensive integration tests. Key implementation details include setting default attribute length limits to prevent Cloud Trace ingestion failures and exposing the connection ID for telemetry correlation. Review feedback highlights an accidental dependency removal in the BOM, discourages hardcoding versions in the POM, suggests a more conservative attribute length limit to ensure span ingestion, and notes the importance of correctly handling InterruptedException in test utilities.

I am having trouble creating individual review comments. Click here to see my feedback.

gapic-libraries-bom/pom.xml (304-310)

high

The removal of google-cloud-bigtable-deps-bom appears to be accidental and is unrelated to the OpenTelemetry changes described in this PR. This could break downstream projects or automation that relies on this BOM entry.

java-bigquery/google-cloud-bigquery-jdbc/pom.xml (383)

medium

Hardcoding the version 2.92.0 for google-cloud-trace is discouraged. If this dependency is managed by the project's BOM, the version should be omitted. If not, consider defining a property in the parent POM to manage this version consistently.

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOpenTelemetry.java (72)

medium

The default limit of 61,440 characters is very close to the 64KB byte limit of GCP Cloud Trace. Since this limit is per attribute, and a span can have multiple attributes plus other metadata, a single 60KB attribute could still cause the entire span to exceed the 64KB backend limit (especially if non-ASCII characters are present, as Java characters are UTF-16). Consider a more conservative default, such as 32768 (32KB), to ensure the span remains within safe ingestion limits.

  private static final String DEFAULT_ATTRIBUTE_LENGTH_LIMIT = "32768";

java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITOpenTelemetryTest.java (255-257)

medium

In Java, do not swallow InterruptedException. When catching it, restore the thread's interrupted status by calling Thread.currentThread().interrupt() and handle the interruption appropriately, such as by throwing a relevant exception to signal that the operation cannot proceed.

      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new RuntimeException("Test interrupted", e);
      } catch (Exception e) {
        // Ignore exceptions during remote lookup and retry
      }
References
  1. In Java, do not swallow InterruptedException. When catching it, restore the thread's interrupted status by calling Thread.currentThread().interrupt() and handle the interruption appropriately.

@keshavdandeva
Copy link
Copy Markdown
Contributor Author

/gemini review

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 OpenTelemetry refinements and integration tests for the BigQuery JDBC driver, including the implementation of default attribute length limits, making getConnectionId() public, and configuring the OpenTelemetryJulHandler to capture all log levels. Feedback identifies a discrepancy between the intended 60KB attribute limit and the 32KB constant used, as well as a potentially accidental deletion of a Bigtable dependency in the BOM file.

I am having trouble creating individual review comments. Click here to see my feedback.

gapic-libraries-bom/pom.xml (304-310)

high

The removal of the google-cloud-bigtable-deps-bom dependency appears to be unrelated to the stated purpose of this pull request (BigQuery JDBC OTel tests and refinements). Please verify if this deletion was intentional, as it could impact downstream projects relying on this BOM.

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOpenTelemetry.java (72)

medium

There is a discrepancy between the PR description (and the code comments on lines 298-300) and the actual value of DEFAULT_ATTRIBUTE_LENGTH_LIMIT. The description specifies a 60KB limit (61,440 characters), but the constant is set to 32768 (32KB).

  private static final String DEFAULT_ATTRIBUTE_LENGTH_LIMIT = "61440";
References
  1. Ensure that comments and constants reflect the current configuration accurately to maintain logical consistency.

@keshavdandeva keshavdandeva marked this pull request as ready for review May 20, 2026 15:38
@keshavdandeva keshavdandeva requested review from a team as code owners May 20, 2026 15:38
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