Skip to content

test(bqjdbc): add unit tests for OTel tracing#12943

Merged
keshavdandeva merged 13 commits intojdbc/feature-branch-otelfrom
jdbc/unit-tests-for-tracing
Apr 29, 2026
Merged

test(bqjdbc): add unit tests for OTel tracing#12943
keshavdandeva merged 13 commits intojdbc/feature-branch-otelfrom
jdbc/unit-tests-for-tracing

Conversation

@keshavdandeva
Copy link
Copy Markdown
Contributor

@keshavdandeva keshavdandeva commented Apr 27, 2026

b/491245568

Changes

Enhanced Unit Testing Infrastructure

  • OpenTelemetryTestUtility: Introduced a shared utility to simplify complex OTel assertions
  • BigQueryStatementTest: Added comprehensive parameterised tracing tests for all execution paths, including attribute validation for queries and batch operations.
  • BigQueryDatabaseMetaDataTest: Instrumented all metadata discovery methods and added corresponding unit tests to verify span generation using parameterised tests

@keshavdandeva keshavdandeva requested review from a team as code owners April 27, 2026 23:40
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 refactors BigQueryDatabaseMetaData by extracting asynchronous fetching logic for tables, columns, and schemas into dedicated methods marked @VisibleForTesting. It also updates OpenTelemetry tracing across BigQueryDatabaseMetaData and BigQueryStatement to ensure better context propagation and adds comprehensive unit tests to verify span generation. The review feedback highlights an inconsistency in the parameters passed to the refactored runGetTablesTaskAsync method and suggests improving the robustness of new tests by avoiding the capture of NullPointerException and using more specific assertions for verifying trace context links.

@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 adds the opentelemetry-sdk-testing dependency and refactors BigQueryDatabaseMetaData to extract background task logic into testable methods, while enhancing OpenTelemetry tracing in both BigQueryDatabaseMetaData and BigQueryStatement. New tests are added to verify span generation and linking. The reviewer identified a missing method runNextPageTaskAsync in BigQueryStatement that will cause compilation errors and recommended using bounded thread pools for background tasks. Additionally, it is suggested to mock dependencies in tests rather than catching NullPointerException to verify span generation more reliably.

@logachev
Copy link
Copy Markdown
Contributor

Please use bqjdbc in the title, so it will be easier to find PRs in the future (e.g. spanner has their own jdbc in that repo)

@keshavdandeva keshavdandeva changed the title test(jdbc): add unit tests for OTel tracing test(bqjdbc): add unit tests for OTel tracing Apr 28, 2026
Base automatically changed from jdbc/add-otel-to-metadata to jdbc/feature-branch-otel April 28, 2026 13:31
@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 testing support and refactors BigQueryDatabaseMetaData and BigQueryStatement to enhance observability and testability. Key changes include extracting background task logic into testable methods and adding comprehensive unit tests to verify span generation and linking. The review feedback suggests a minor optimization in BigQueryStatement to cache the tracer instance instead of repeatedly fetching it within a pagination loop.

@keshavdandeva keshavdandeva requested a review from logachev April 28, 2026 16:43
@keshavdandeva keshavdandeva merged commit 20bb4f9 into jdbc/feature-branch-otel Apr 29, 2026
96 checks passed
@keshavdandeva keshavdandeva deleted the jdbc/unit-tests-for-tracing branch April 29, 2026 09:59
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