Skip to content

Commit cc8b4b2

Browse files
committed
added examples to required classes for telemetry
Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent 7815ef3 commit cc8b4b2

File tree

9 files changed

+80
-19
lines changed

9 files changed

+80
-19
lines changed

examples/query_execute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
) as connection:
99

1010
with connection.cursor() as cursor:
11-
cursor.execute("SELECT * FROM main.eng_lumberjack.staging_frontend_log_sql_driver_log limit 1")
11+
cursor.execute("SELECT * FROM default.diamonds LIMIT 2")
1212
result = cursor.fetchall()
1313

1414
for row in result:
15-
print(row)
15+
print(row)

src/databricks/sql/telemetry/DriverConnectionParameters.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,21 @@ class DriverConnectionParameters:
2222

2323
def to_json(self):
2424
return json.dumps(asdict(self))
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+
# enableComplexDatatypeSupport = true,
40+
# azureTenantId = "1234567890abcdef",
41+
# socketTimeout = 10000
42+
# )

src/databricks/sql/telemetry/DriverErrorInfo.py

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

1010
def to_json(self):
1111
return json.dumps(asdict(self))
12+
13+
# Required for ErrorLogs
14+
# DriverErrorInfo errorInfo = new DriverErrorInfo(
15+
# errorName="CONNECTION_ERROR",
16+
# stackTrace="Connection failure while using the Databricks SQL Python connector. Failed to connect to server: https://my-workspace.cloud.databricks.com\n" +
17+
# "databricks.sql.exc.OperationalError: Connection refused: connect\n" +
18+
# "at databricks.sql.thrift_backend.ThriftBackend.make_request(ThriftBackend.py:329)\n" +
19+
# "at databricks.sql.thrift_backend.ThriftBackend.attempt_request(ThriftBackend.py:366)\n" +
20+
# "at databricks.sql.thrift_backend.ThriftBackend.open_session(ThriftBackend.py:575)\n" +
21+
# "at databricks.sql.client.Connection.__init__(client.py:69)\n" +
22+
# "at databricks.sql.client.connect(connection.py:123)")
Lines changed: 15 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,20 @@ 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+
# Part of TelemetryEvent
24+
# DriverSystemConfiguration systemConfig = new DriverSystemConfiguration(
25+
# driver_version = "2.9.3",
26+
# os_name = "Darwin",
27+
# os_version = "24.4.0",
28+
# os_arch = "arm64",
29+
# runtime_name = "CPython",
30+
# runtime_version = "3.13.3",
31+
# runtime_vendor = "cpython",
32+
# client_app_name = "databricks-sql-python",
33+
# locale_name = "en_US",
34+
# driver_name = "databricks-sql-python",
35+
# char_set_encoding = "UTF-8"
36+
# )

src/databricks/sql/telemetry/DriverVolumeOperation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
DriverVolumeOperationType,
55
)
66

7-
87
@dataclass
98
class DriverVolumeOperation:
109
volume_operation_type: DriverVolumeOperationType
1110
volume_path: str
1211

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

src/databricks/sql/telemetry/FrontendLogContext.py

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

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

src/databricks/sql/telemetry/HostDetails.py

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

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

src/databricks/sql/telemetry/SqlExecutionEvent.py

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

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

src/databricks/sql/telemetry/TelemetryClientContext.py

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

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

0 commit comments

Comments
 (0)