feat(jdbc): implement OTel SDK and export tracing logic#13039
feat(jdbc): implement OTel SDK and export tracing logic#13039keshavdandeva wants to merge 6 commits intojdbc/feature-branch-otelfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements OpenTelemetry SDK initialization and OTLP exporting for the BigQuery JDBC driver. It introduces new connection properties for telemetry credentials and project IDs, and implements a caching mechanism for OTel SDK instances. Review feedback identifies a potential bug in the caching logic where configuration flags are missing from the cache key, and a resource leak caused by registering multiple shutdown hooks. Suggestions were provided to include flags in the cache key and use a single global shutdown hook to manage SDK lifecycle.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements auto-configuration and caching for OpenTelemetry SDK instances within the BigQuery JDBC driver. It introduces new connection properties for GCP telemetry credentials and project IDs, enabling more flexible telemetry setup. The review feedback identifies critical risks regarding potential NullPointerExceptions when unboxing Boolean flags and suggests a more robust cache key construction to prevent key collisions in the SDK cache.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements OpenTelemetry auto-configuration for the BigQuery JDBC driver, enabling the use of GCP-specific telemetry credentials and project IDs. It introduces a caching layer for OpenTelemetrySdk instances and a shutdown hook for resource cleanup. Feedback points out that the OTLP exporter configuration lacks proper authentication for GCP and identifies a potential memory leak in connection management. Further suggestions include refining the SDK caching logic to remove redundant keys and ensuring the shutdown hook is exception-safe.
b/491238299
This PR completes the implementation of the OpenTelemetry SDK lifecycle and cross-project authentication for the BigQuery JDBC driver. It introduces thread-safe caching of heavy OTel SDK instances to support multi-project tracing without global side effects.
Changes
BigQueryJdbcOpenTelemetry.javaConcurrentHashMapcachesOpenTelemetrySdkinstances, keyed by a concatenated string ofProjectIdandCredentialsgetOpenTelemetry()method lazily loads and initializes the SDK only when requested and not present in the cache.BigQueryJdbcUrlUtility.javagcpTelemetryCredentialsandgcpTelemetryProjectIdare added to connection properties.BigQueryJdbcOAuthUtility.javaisJson()helper method is changed from private to package-private to allow reuse inBigQueryJdbcOpenTelemetry.BigQueryConnection.javaBoolean.TRUE.equals()when checkingenableGcpLogExporterandenableGcpTraceExporterto safely handle cases where these properties are not specifiednulland avoidNullPointerExceptionduring auto-unboxing.BigQueryJdbcOpenTelemetryTest.javaBigQueryArrowStructTest.java