Class TelemetryManager (1.10.0)

public final class TelemetryManager implements AutoCloseable

Thread-safe singleton hub managing the lifecycle of TelemetryBatcher for client-side diagnostic and usage telemetry in the BigQuery JDBC driver.

All telemetry operations are wrapped in exception safeguards so that failures in metric collection or batch dispatching never impact standard JDBC functionality.

Inheritance

java.lang.Object > TelemetryManager

Implements

AutoCloseable

Static Methods

closeInstance()

public static synchronized void closeInstance()

Flushes pending buffered metrics and shuts down the shared instance.

extractErrorCode(Throwable t)

public static int extractErrorCode(Throwable t)

Extracts the numeric error code from the throwable chain. Traverses causes to unpack BigQueryException (HTTP status codes) or SQLException error codes. Returns 1000 as the fallback driver error code.

Parameter
Name Description
t Throwable
Returns
Type Description
int

extractSqlState(Throwable t)

public static String extractSqlState(Throwable t)

Extracts the SQLState from the throwable chain. SQLStates are five-character strings.

Returns empty String when no SQLState is present.

Parameter
Name Description
t Throwable
Returns
Type Description
String

getInstance()

public static TelemetryManager getInstance()

Initializes or replaces the shared TelemetryManager instance with default configuration and transport.

Returns
Type Description
TelemetryManager

getInstance(Properties properties)

public static TelemetryManager getInstance(Properties properties)
Parameter
Name Description
properties Properties
Returns
Type Description
TelemetryManager

isInitialized()

public static boolean isInitialized()

Helper to check if an active instance is present and initialized.

Returns
Type Description
boolean

recordConnectionAttempt(Status status, int errorCode, AuthenticationType authType)

public static void recordConnectionAttempt(Status status, int errorCode, AuthenticationType authType)
Parameters
Name Description
status Status
errorCode int
authType AuthenticationType

recordError(int errorCode, String errorSqlState, String methodName)

public static void recordError(int errorCode, String errorSqlState, String methodName)
Parameters
Name Description
errorCode int
errorSqlState String
methodName String

recordFeatureUsage(DriverFeature feature)

public static void recordFeatureUsage(DriverFeature feature)
Parameter
Name Description
feature DriverFeature

recordFeatureUsage(DriverFeature feature, String customFeatureName)

public static void recordFeatureUsage(DriverFeature feature, String customFeatureName)
Parameters
Name Description
feature DriverFeature
customFeatureName String

recordStatementExecution(StatementExecution.Builder statementExecutionBuilder, long durationMs)

public static void recordStatementExecution(StatementExecution.Builder statementExecutionBuilder, long durationMs)
Parameters
Name Description
statementExecutionBuilder StatementExecution.Builder
durationMs long

runSafely(Runnable action)

public static void runSafely(Runnable action)

Executes a telemetry logging operation safely inside an exception-isolated block. Guaranteed to catch all Throwable exceptions to protect JDBC driver operations.

Parameter
Name Description
action Runnable

toAuthenticationType(int oauthType)

public static AuthenticationType toAuthenticationType(int oauthType)
Parameter
Name Description
oauthType int
Returns
Type Description
AuthenticationType

toStatementType(JobStatistics.QueryStatistics.StatementType bqStatementType)

public static StatementType toStatementType(JobStatistics.QueryStatistics.StatementType bqStatementType)
Parameter
Name Description
bqStatementType com.google.cloud.bigquery.JobStatistics.QueryStatistics.StatementType
Returns
Type Description
StatementType

Methods

close()

public void close()