@@ -20,6 +20,7 @@ import { LogLevel } from '../contracts/IDBSQLLogger';
2020import { TelemetryMetric , DEFAULT_TELEMETRY_CONFIG } from './types' ;
2121import { CircuitBreakerRegistry } from './CircuitBreaker' ;
2222import ExceptionClassifier from './ExceptionClassifier' ;
23+ import { buildUrl } from './urlUtils' ;
2324
2425/**
2526 * Databricks telemetry log format for export.
@@ -37,19 +38,33 @@ interface DatabricksTelemetryLog {
3738 sql_driver_log : {
3839 session_id ?: string ;
3940 sql_statement_id ?: string ;
41+ system_configuration ?: {
42+ driver_version ?: string ;
43+ runtime_name ?: string ;
44+ runtime_version ?: string ;
45+ runtime_vendor ?: string ;
46+ os_name ?: string ;
47+ os_version ?: string ;
48+ os_arch ?: string ;
49+ driver_name ?: string ;
50+ client_app_name ?: string ;
51+ } ;
52+ driver_connection_params ?: any ;
4053 operation_latency_ms ?: number ;
4154 sql_operation ?: {
42- execution_result_format ?: string ;
55+ execution_result ?: string ;
4356 chunk_details ?: {
44- chunk_count : number ;
45- total_bytes ?: number ;
57+ total_chunks_present ?: number ;
58+ total_chunks_iterated ?: number ;
59+ initial_chunk_latency_millis ?: number ;
60+ slowest_chunk_latency_millis ?: number ;
61+ sum_chunks_download_time_millis ?: number ;
4662 } ;
4763 } ;
4864 error_info ?: {
4965 error_name : string ;
5066 stack_trace : string ;
5167 } ;
52- driver_config ?: any ;
5368 } ;
5469 } ;
5570}
@@ -190,8 +205,8 @@ export default class DatabricksTelemetryExporter {
190205 const authenticatedExport =
191206 config . telemetryAuthenticatedExport ?? DEFAULT_TELEMETRY_CONFIG . authenticatedExport ;
192207 const endpoint = authenticatedExport
193- ? `https:// ${ this . host } /api/2.0/sql/ telemetry-ext`
194- : `https:// ${ this . host } /api/2.0/sql/ telemetry-unauth` ;
208+ ? buildUrl ( this . host , '/ telemetry-ext' )
209+ : buildUrl ( this . host , '/ telemetry-unauth' ) ;
195210
196211 // Format payload
197212 const payload : DatabricksTelemetryPayload = {
@@ -231,7 +246,7 @@ export default class DatabricksTelemetryExporter {
231246 */
232247 private toTelemetryLog ( metric : TelemetryMetric ) : DatabricksTelemetryLog {
233248 const log : DatabricksTelemetryLog = {
234- workspace_id : metric . workspaceId ,
249+ // workspace_id: metric.workspaceId, // TODO: Determine if this should be numeric or omitted
235250 frontend_log_event_id : this . generateUUID ( ) ,
236251 context : {
237252 client_context : {
@@ -247,21 +262,29 @@ export default class DatabricksTelemetryExporter {
247262 } ,
248263 } ;
249264
250- // Add metric-specific fields
265+ // Add metric-specific fields based on proto definition
251266 if ( metric . metricType === 'connection' && metric . driverConfig ) {
252- log . entry . sql_driver_log . driver_config = metric . driverConfig ;
267+ // Map driverConfig to system_configuration (snake_case as per proto)
268+ log . entry . sql_driver_log . system_configuration = {
269+ driver_version : metric . driverConfig . driverVersion ,
270+ driver_name : metric . driverConfig . driverName ,
271+ runtime_name : 'Node.js' ,
272+ runtime_version : metric . driverConfig . nodeVersion ,
273+ os_name : metric . driverConfig . platform ,
274+ os_version : metric . driverConfig . osVersion ,
275+ } ;
253276 } else if ( metric . metricType === 'statement' ) {
254277 log . entry . sql_driver_log . operation_latency_ms = metric . latencyMs ;
255278
256279 if ( metric . resultFormat || metric . chunkCount ) {
257280 log . entry . sql_driver_log . sql_operation = {
258- execution_result_format : metric . resultFormat ,
281+ execution_result : metric . resultFormat ,
259282 } ;
260283
261284 if ( metric . chunkCount && metric . chunkCount > 0 ) {
262285 log . entry . sql_driver_log . sql_operation . chunk_details = {
263- chunk_count : metric . chunkCount ,
264- total_bytes : metric . bytesDownloaded ,
286+ total_chunks_present : metric . chunkCount ,
287+ total_chunks_iterated : metric . chunkCount ,
265288 } ;
266289 }
267290 }
0 commit comments