Skip to content

feat(bqjdbc): Integrate the PerConnectionFileHandler with BigQueryJdbcRootLogger#12933

Open
Neenu1995 wants to merge 4 commits intomainfrom
ns/logger-integ-per-conn-logs
Open

feat(bqjdbc): Integrate the PerConnectionFileHandler with BigQueryJdbcRootLogger#12933
Neenu1995 wants to merge 4 commits intomainfrom
ns/logger-integ-per-conn-logs

Conversation

@Neenu1995
Copy link
Copy Markdown
Contributor

@Neenu1995 Neenu1995 commented Apr 25, 2026

  • [b/501081671] Integrate the PerConnectionFileHandler with BigQueryJdbcRootLogger
  • [b/501081158] Refactor BigQueryConnection to generate a unique ID for each connection
  • [b/501081558] Update the Log Record format to inject the Connection-ID tag
  • [b/501081433] Integrate MDC context lifecycle bindings into all entry-level JDBC methods in BigQueryConnection and BigQueryStatement

@Neenu1995 Neenu1995 requested review from a team as code owners April 25, 2026 00:24
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 implements connection-specific logging by introducing a unique connectionId and utilizing Mapped Diagnostic Context (MDC) across BigQueryConnection and BigQueryStatement. Key changes include wrapping JDBC methods in try-finally blocks to manage MDC state and updating the logging formatter to include connection identifiers. Review feedback highlights potential NullPointerException vulnerabilities in BigQueryStatement when accessing the connection object after it has been closed, as well as a suggestion to refine MDC cleanup to prevent clearing external application context.

// Example: 2026-04-22 10:16:00.123 INFO 12345 --- [main ]
// com.google.cloud.bigquery.jdbc.BigQueryConnection connect : Connection
// successful
// Expected log format: yyyy-MM-dd HH:mm:ss.SSS [CONNECTION_ID] LEVEL PID --- [THREAD] CLASS
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need Connection_ID? Isn't it 1 file per connection now?

addOpenStatements(currentStatement);
return currentStatement;
} finally {
BigQueryJdbcMdc.clear();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make registerInstance() to return AutoCloseable() object so we don't need to call clear() every time?

@@ -706,102 +782,125 @@ public void clearWarnings() {

@Override
public boolean getAutoCommit() {
checkClosed();
return this.autoCommit;
try {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest using the same approach from Telemetry.

Moving real logic to the private Impl() so it is easier to distinguish business logic vs logging setup\tracer setup etc.

Now multiple places have try/catch/finally blocks inside another try\catch\finally and that's difficult to read.

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