test(bqjdbc): add unit tests for OTel tracing#12943
test(bqjdbc): add unit tests for OTel tracing#12943keshavdandeva merged 13 commits intojdbc/feature-branch-otelfrom
Conversation
…er the blocking operation `buffer.take()`
There was a problem hiding this comment.
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.
|
/gemini review |
There was a problem hiding this comment.
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.
|
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) |
|
/gemini review |
There was a problem hiding this comment.
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.
b/491245568
Changes
Enhanced Unit Testing Infrastructure
OpenTelemetryTestUtility: Introduced a shared utility to simplify complex OTel assertionsBigQueryStatementTest: 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