Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/DBSQLClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I

private authType?: string;

private useProxy?: boolean;

private telemetryClient?: TelemetryClient;

private telemetryEmitter?: TelemetryEventEmitter;
Expand Down Expand Up @@ -425,6 +427,7 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
// Connection parameters
httpPath: this.httpPath,
enableMetricViewMetadata: this.config.enableMetricViewMetadata,
useProxy: this.useProxy,
};
}

Expand Down Expand Up @@ -604,6 +607,7 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
this.host = options.host;
this.httpPath = options.path;
this.authType = this.mapAuthType(options);
this.useProxy = Boolean(options.proxy);

// Store enableMetricViewMetadata configuration
if (options.enableMetricViewMetadata !== undefined) {
Expand Down
48 changes: 47 additions & 1 deletion lib/telemetry/DatabricksTelemetryExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,24 @@ interface DatabricksTelemetryLog {
char_set_encoding?: string;
process_name?: string;
};
auth_type?: string;
driver_connection_params?: {
host_info?: { host_url?: string };
http_path?: string;
mode?: string;
use_proxy?: boolean;
enable_arrow?: boolean;
enable_direct_results?: boolean;
socket_timeout?: number;
enable_metric_view_metadata?: boolean;
};
operation_latency_ms?: number;
sql_operation?: {
execution_result?: string;
is_compressed?: boolean;
operation_detail?: {
operation_type?: string;
};
chunk_details?: {
total_chunks_present?: number;
total_chunks_iterated?: number;
Expand Down Expand Up @@ -368,6 +383,11 @@ export default class DatabricksTelemetryExporter {
if (metric.latencyMs !== undefined) {
log.entry.sql_driver_log.operation_latency_ms = metric.latencyMs;
}
if (metric.operationType) {
log.entry.sql_driver_log.sql_operation = {
operation_detail: { operation_type: metric.operationType },
};
}
if (metric.driverConfig && includeCorrelation) {
// system_configuration is a high-entropy client fingerprint (OS, arch,
// locale, process, runtime). Only ship on the authenticated path.
Expand All @@ -384,15 +404,41 @@ export default class DatabricksTelemetryExporter {
char_set_encoding: metric.driverConfig.charSetEncoding,
process_name: sanitizeProcessName(metric.driverConfig.processName) || undefined,
};

// auth_type and host/http-path are workspace-correlated, so they ride
// the same auth-only path as system_configuration.
if (metric.driverConfig.authType) {
log.entry.sql_driver_log.auth_type = metric.driverConfig.authType;
}
log.entry.sql_driver_log.driver_connection_params = {
host_info: { host_url: this.host },
http_path: metric.driverConfig.httpPath,
mode: 'THRIFT',
use_proxy: metric.driverConfig.useProxy,
enable_arrow: metric.driverConfig.arrowEnabled,
enable_direct_results: metric.driverConfig.directResultsEnabled,
socket_timeout: metric.driverConfig.socketTimeout,
enable_metric_view_metadata: metric.driverConfig.enableMetricViewMetadata,
};
}
} else if (metric.metricType === 'statement') {
log.entry.sql_driver_log.operation_latency_ms = metric.latencyMs;

if (metric.resultFormat || metric.chunkCount) {
if (metric.resultFormat || metric.chunkCount || metric.operationType || metric.compressed !== undefined) {
log.entry.sql_driver_log.sql_operation = {
execution_result: metric.resultFormat,
};

if (metric.compressed !== undefined) {
log.entry.sql_driver_log.sql_operation.is_compressed = metric.compressed;
}

if (metric.operationType) {
log.entry.sql_driver_log.sql_operation.operation_detail = {
operation_type: metric.operationType,
};
}

if ((metric.chunkCount ?? 0) > 0) {
log.entry.sql_driver_log.sql_operation.chunk_details = {
total_chunks_present: metric.chunkCount,
Expand Down
4 changes: 2 additions & 2 deletions lib/telemetry/telemetryTypeMappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export function mapOperationTypeToTelemetryType(operationType?: TOperationType):
/**
* Map Thrift TSparkRowSetType to telemetry ExecutionResult.Format enum string.
*/
export function mapResultFormatToTelemetryType(resultFormat?: TSparkRowSetType): string | undefined {
export function mapResultFormatToTelemetryType(resultFormat?: TSparkRowSetType): string {
if (resultFormat === undefined) {
return undefined;
return 'FORMAT_UNSPECIFIED';
}

switch (resultFormat) {
Expand Down
3 changes: 3 additions & 0 deletions lib/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ export interface DriverConfiguration {

/** Whether metric view metadata is enabled */
enableMetricViewMetadata?: boolean;

/** Whether an HTTP/SOCKS proxy is configured on the connection */
useProxy?: boolean;
}

/**
Expand Down
Loading