Skip to content

Commit cbc9ebf

Browse files
committed
Added classes required for telemetry
Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent 74c6463 commit cbc9ebf

9 files changed

+88
-20
lines changed

src/databricks/sql/telemetry/DriverConnectionParameters.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,33 @@
99
@dataclass
1010
class DriverConnectionParameters:
1111
http_path: str
12-
driver_mode: DatabricksClientType
13-
host_details: HostDetails
12+
mode: DatabricksClientType
13+
host_info: HostDetails
1414
auth_mech: AuthMech
1515
auth_flow: AuthFlow
1616
auth_scope: str
1717
discovery_url: str
1818
allowed_volume_ingestion_paths: str
19-
enable_complex_datatype_support: bool
2019
azure_tenant_id: str
2120
socket_timeout: int
2221

2322
def to_json(self):
2423
return json.dumps(asdict(self))
24+
25+
26+
# Part of TelemetryEvent
27+
# DriverConnectionParameters connectionParams = new DriverConnectionParameters(
28+
# httpPath = " /sql/1.0/endpoints/1234567890abcdef",
29+
# driverMode = "THRIFT",
30+
# hostDetails = new HostDetails(
31+
# hostUrl = "https://my-workspace.cloud.databricks.com",
32+
# port = 443
33+
# ),
34+
# authMech = "OAUTH",
35+
# authFlow = "AZURE_MANAGED_IDENTITIES",
36+
# authScope = "sql",
37+
# discoveryUrl = "https://example-url",
38+
# allowedVolumeIngestionPaths = "[]",
39+
# azureTenantId = "1234567890abcdef",
40+
# socketTimeout = 10000
41+
# )

src/databricks/sql/telemetry/DriverErrorInfo.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,15 @@ class DriverErrorInfo:
99

1010
def to_json(self):
1111
return json.dumps(asdict(self))
12+
13+
14+
# Required for ErrorLogs
15+
# DriverErrorInfo errorInfo = new DriverErrorInfo(
16+
# errorName="CONNECTION_ERROR",
17+
# stackTrace="Connection failure while using the Databricks SQL Python connector. Failed to connect to server: https://my-workspace.cloud.databricks.com\n" +
18+
# "databricks.sql.exc.OperationalError: Connection refused: connect\n" +
19+
# "at databricks.sql.thrift_backend.ThriftBackend.make_request(ThriftBackend.py:329)\n" +
20+
# "at databricks.sql.thrift_backend.ThriftBackend.attempt_request(ThriftBackend.py:366)\n" +
21+
# "at databricks.sql.thrift_backend.ThriftBackend.open_session(ThriftBackend.py:575)\n" +
22+
# "at databricks.sql.client.Connection.__init__(client.py:69)\n" +
23+
# "at databricks.sql.client.connect(connection.py:123)")
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import json
22
from dataclasses import dataclass, asdict
3-
import platform
4-
import sys
5-
import locale
63
from databricks.sql import __version__
74

85

@@ -20,18 +17,21 @@ class DriverSystemConfiguration:
2017
driver_name: str
2118
char_set_encoding: str
2219

23-
def __init__(self):
24-
self.driver_version = __version__
25-
self.os_name = platform.system()
26-
self.os_version = platform.version()
27-
self.os_arch = platform.machine()
28-
self.runtime_name = platform.python_implementation()
29-
self.runtime_version = platform.python_version()
30-
self.runtime_vendor = sys.implementation.name
31-
self.client_app_name = "databricks-sql-python"
32-
self.locale_name = locale.getdefaultlocale()[0]
33-
self.driver_name = "databricks-sql-python"
34-
self.char_set_encoding = "UTF-8"
35-
3620
def to_json(self):
3721
return json.dumps(asdict(self))
22+
23+
24+
# Part of TelemetryEvent
25+
# DriverSystemConfiguration systemConfig = new DriverSystemConfiguration(
26+
# driver_version = "2.9.3",
27+
# os_name = "Darwin",
28+
# os_version = "24.4.0",
29+
# os_arch = "arm64",
30+
# runtime_name = "CPython",
31+
# runtime_version = "3.13.3",
32+
# runtime_vendor = "cpython",
33+
# client_app_name = "databricks-sql-python",
34+
# locale_name = "en_US",
35+
# driver_name = "databricks-sql-python",
36+
# char_set_encoding = "UTF-8"
37+
# )

src/databricks/sql/telemetry/DriverVolumeOperation.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ class DriverVolumeOperation:
1212

1313
def to_json(self):
1414
return json.dumps(asdict(self))
15+
16+
17+
# Part of TelemetryEvent
18+
# DriverVolumeOperation volumeOperation = new DriverVolumeOperation(
19+
# volumeOperationType = "LIST",
20+
# volumePath = "/path/to/volume"
21+
# )

src/databricks/sql/telemetry/FrontendLogContext.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,12 @@ class FrontendLogContext:
99

1010
def to_json(self):
1111
return json.dumps(asdict(self))
12+
13+
14+
# used in TelemetryFrontendLog
15+
# FrontendLogContext frontendLogContext = new FrontendLogContext(
16+
# clientContext = new TelemetryClientContext(
17+
# timestampMillis = 1716489600000,
18+
# userAgent = "databricks-sql-python-test"
19+
# )
20+
# )

src/databricks/sql/telemetry/HostDetails.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ class HostDetails:
99

1010
def to_json(self):
1111
return json.dumps(asdict(self))
12+
13+
14+
# Part of DriverConnectionParameters
15+
# HostDetails hostDetails = new HostDetails(
16+
# hostUrl = "https://my-workspace.cloud.databricks.com",
17+
# port = 443
18+
# )

src/databricks/sql/telemetry/SqlExecutionEvent.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,12 @@ class SqlExecutionEvent:
1313

1414
def to_json(self):
1515
return json.dumps(asdict(self))
16+
17+
18+
# Part of TelemetryEvent
19+
# SqlExecutionEvent sqlExecutionEvent = new SqlExecutionEvent(
20+
# statementType = "QUERY",
21+
# isCompressed = true,
22+
# executionResult = "INLINE_ARROW",
23+
# retryCount = 0
24+
# )

src/databricks/sql/telemetry/TelemetryClientContext.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ class TelemetryClientContext:
99

1010
def to_json(self):
1111
return json.dumps(asdict(self))
12+
13+
14+
# used in FrontendLogContext
15+
# TelemetryClientContext clientContext = new TelemetryClientContext(
16+
# timestampMillis = 1716489600000,
17+
# userAgent = "databricks-sql-python-test"
18+
# )

src/databricks/sql/telemetry/TelemetryEvent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TelemetryEvent:
1919
vol_operation: DriverVolumeOperation
2020
sql_operation: SqlExecutionEvent
2121
error_info: DriverErrorInfo
22-
latency: int
22+
operation_latency_ms: int
2323

2424
def to_json(self):
2525
return json.dumps(asdict(self))

0 commit comments

Comments
 (0)