Skip to content

Commit 28bf612

Browse files
committed
error log for auth provider, ThriftDatabricksClient
Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent 6f13273 commit 28bf612

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

src/databricks/sql/session.py

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from databricks.sql.backend.thrift_backend import ThriftDatabricksClient
1111
from databricks.sql.backend.databricks_client import DatabricksClient
1212
from databricks.sql.backend.types import SessionId
13+
from databricks.sql.telemetry.telemetry_client import TelemetryClientFactory
1314

1415
logger = logging.getLogger(__name__)
1516

@@ -40,9 +41,18 @@ def __init__(
4041
self.catalog = catalog
4142
self.schema = schema
4243

43-
self.auth_provider = get_python_sql_connector_auth_provider(
44-
server_hostname, **kwargs
45-
)
44+
try:
45+
self.auth_provider = get_python_sql_connector_auth_provider(
46+
server_hostname, **kwargs
47+
)
48+
except Exception as e:
49+
TelemetryClientFactory.connection_failure_log(
50+
error_name="Exception",
51+
error_message=str(e),
52+
host_url=server_hostname,
53+
http_path=http_path,
54+
port=self.port,
55+
)
4656

4757
user_agent_entry = kwargs.get("user_agent_entry")
4858
if user_agent_entry is None:
@@ -74,16 +84,26 @@ def __init__(
7484
tls_client_cert_key_password=kwargs.get("_tls_client_cert_key_password"),
7585
)
7686

77-
self.backend: DatabricksClient = ThriftDatabricksClient(
78-
self.host,
79-
self.port,
80-
http_path,
81-
(http_headers or []) + base_headers,
82-
self.auth_provider,
83-
ssl_options=self._ssl_options,
84-
_use_arrow_native_complex_types=_use_arrow_native_complex_types,
85-
**kwargs,
86-
)
87+
try:
88+
self.backend: DatabricksClient = ThriftDatabricksClient(
89+
self.host,
90+
self.port,
91+
http_path,
92+
(http_headers or []) + base_headers,
93+
self.auth_provider,
94+
ssl_options=self._ssl_options,
95+
_use_arrow_native_complex_types=_use_arrow_native_complex_types,
96+
**kwargs,
97+
)
98+
except Exception as e:
99+
TelemetryClientFactory.connection_failure_log(
100+
error_name="Exception",
101+
error_message=str(e),
102+
host_url=server_hostname,
103+
http_path=http_path,
104+
port=self.port,
105+
user_agent=self.useragent_header,
106+
)
87107

88108
self.protocol_version = None
89109

0 commit comments

Comments
 (0)