feat(bqjdbc): Add BigQueryJdbcMdc context to entry level methods - part 3#12954
feat(bqjdbc): Add BigQueryJdbcMdc context to entry level methods - part 3#12954
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements comprehensive MDC (Mapped Diagnostic Context) tracking and entry-level logging across the BigQuery JDBC driver. Key changes include refactoring public methods in BigQueryArrowResultSet, BigQueryJsonResultSet, BigQueryPreparedStatement, and BigQueryDatabaseMetaData to wrap operations in MDC context blocks, while moving core logic to internal implementation methods. Additionally, BigQueryJdbcMdc was updated to support nested context registration. The review feedback focuses on ensuring the close() method in BigQueryJsonResultSet is idempotent, replacing unsafe class casts with the standard JDBC unwrap pattern in BigQueryResultSetMetadata, and optimizing performance by eliminating redundant MDC registrations during internal method calls.
b/501081433
MDC Context registration:
MDC Nesting Support: Updated BigQueryJdbcMdc.java to use a save-and-restore pattern, supporting safe nesting of contexts across different connections.
Metadata Refactor: Split methods longer than 10 lines in BigQueryDatabaseMetaData and BigQueryResultSetMetadata to separate MDC setup from execution logic.
Logging Enhancements:
Cleanup: Made LOG static in metadata and statement classes to support static contexts and cleaned up method signatures by removing passed logger instances.