Skip to content

feat(bigquery-jdbc): add otel trace and span IDs to local logs - #13935

Open
keshavdandeva wants to merge 2 commits into
mainfrom
jdbc/add-otel-to-local-logs
Open

feat(bigquery-jdbc): add otel trace and span IDs to local logs#13935
keshavdandeva wants to merge 2 commits into
mainfrom
jdbc/add-otel-to-local-logs

Conversation

@keshavdandeva

Copy link
Copy Markdown
Contributor

b/538631816

This PR integrates OpenTelemetry tracing context into the JDBC driver's local file logging system, bringing it to parity with the existing Google Cloud Logging export integration.

Key Changes:

  • BigQueryJdbcRootLogger.java: Updated the root formatter to extract the active TraceId and SpanId from the current OpenTelemetry thread context. When a valid trace is active, local logs will now automatically include a [trace_id=... span_id=...] block.
  • BigQueryJdbcRootLoggerTest.java: Added testFormatterWithOpenTelemetrySpan to verify the formatter correctly extracts and formats IDs when a span is active.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request integrates OpenTelemetry tracing into the BigQuery JDBC driver's root logger, appending trace and span IDs to the log format when a valid span is active, and adds a unit test to verify this behavior. The review feedback suggests optimizing performance in the logging path by appending the trace block directly to the existing StringBuilder instead of creating intermediate concatenated strings.

@keshavdandeva
keshavdandeva marked this pull request as ready for review July 28, 2026 21:35
@keshavdandeva
keshavdandeva requested review from a team as code owners July 28, 2026 21:35
if (!spanContext.isValid()) {
return "";
}
return "[trace_id="

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.

nit: is returning StringBuilder that is being appended faster?

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