1- import json
2- from dataclasses import dataclass , asdict
1+ from dataclasses import dataclass
32from databricks .sql .telemetry .models .enums import (
43 AuthMech ,
54 AuthFlow ,
98 ExecutionResultFormat ,
109)
1110from typing import Optional
12- from databricks .sql .telemetry .utils import to_json_compact
11+ from databricks .sql .telemetry .utils import JsonSerializableMixin
1312
1413
1514@dataclass
16- class HostDetails :
15+ class HostDetails ( JsonSerializableMixin ) :
1716 """
1817 Represents the host connection details for a Databricks workspace.
1918
@@ -25,12 +24,9 @@ class HostDetails:
2524 host_url : str
2625 port : int
2726
28- def to_json (self ):
29- return to_json_compact (self )
30-
3127
3228@dataclass
33- class DriverConnectionParameters :
29+ class DriverConnectionParameters ( JsonSerializableMixin ) :
3430 """
3531 Contains all connection parameters used to establish a connection to Databricks SQL.
3632 This includes authentication details, host information, and connection settings.
@@ -51,12 +47,9 @@ class DriverConnectionParameters:
5147 auth_flow : Optional [AuthFlow ] = None
5248 socket_timeout : Optional [int ] = None
5349
54- def to_json (self ):
55- return to_json_compact (self )
56-
5750
5851@dataclass
59- class DriverSystemConfiguration :
52+ class DriverSystemConfiguration ( JsonSerializableMixin ) :
6053 """
6154 Contains system-level configuration information about the client environment.
6255 This includes details about the operating system, runtime, and driver version.
@@ -87,12 +80,9 @@ class DriverSystemConfiguration:
8780 client_app_name : Optional [str ] = None
8881 locale_name : Optional [str ] = None
8982
90- def to_json (self ):
91- return to_json_compact (self )
92-
9383
9484@dataclass
95- class DriverVolumeOperation :
85+ class DriverVolumeOperation ( JsonSerializableMixin ) :
9686 """
9787 Represents a volume operation performed by the driver.
9888 Used for tracking volume-related operations in telemetry.
@@ -105,12 +95,9 @@ class DriverVolumeOperation:
10595 volume_operation_type : DriverVolumeOperationType
10696 volume_path : str
10797
108- def to_json (self ):
109- return to_json_compact (self )
110-
11198
11299@dataclass
113- class DriverErrorInfo :
100+ class DriverErrorInfo ( JsonSerializableMixin ) :
114101 """
115102 Contains detailed information about errors that occur during driver operations.
116103 Used for error tracking and debugging in telemetry.
@@ -123,12 +110,9 @@ class DriverErrorInfo:
123110 error_name : str
124111 stack_trace : str
125112
126- def to_json (self ):
127- return to_json_compact (self )
128-
129113
130114@dataclass
131- class SqlExecutionEvent :
115+ class SqlExecutionEvent ( JsonSerializableMixin ) :
132116 """
133117 Represents a SQL query execution event.
134118 Contains details about the query execution, including type, compression, and result format.
@@ -145,12 +129,9 @@ class SqlExecutionEvent:
145129 execution_result : ExecutionResultFormat
146130 retry_count : int
147131
148- def to_json (self ):
149- return to_json_compact (self )
150-
151132
152133@dataclass
153- class TelemetryEvent :
134+ class TelemetryEvent ( JsonSerializableMixin ) :
154135 """
155136 Main telemetry event class that aggregates all telemetry data.
156137 Contains information about the session, system configuration, connection parameters,
@@ -177,6 +158,3 @@ class TelemetryEvent:
177158 sql_operation : Optional [SqlExecutionEvent ] = None
178159 error_info : Optional [DriverErrorInfo ] = None
179160 operation_latency_ms : Optional [int ] = None
180-
181- def to_json (self ):
182- return to_json_compact (self )
0 commit comments