|
10 | 10 | from databricks.sql.backend.thrift_backend import ThriftDatabricksClient |
11 | 11 | from databricks.sql.backend.databricks_client import DatabricksClient |
12 | 12 | from databricks.sql.backend.types import SessionId |
| 13 | +from databricks.sql.telemetry.telemetry_client import TelemetryClientFactory |
13 | 14 |
|
14 | 15 | logger = logging.getLogger(__name__) |
15 | 16 |
|
@@ -40,9 +41,18 @@ def __init__( |
40 | 41 | self.catalog = catalog |
41 | 42 | self.schema = schema |
42 | 43 |
|
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 | + ) |
46 | 56 |
|
47 | 57 | user_agent_entry = kwargs.get("user_agent_entry") |
48 | 58 | if user_agent_entry is None: |
@@ -74,16 +84,26 @@ def __init__( |
74 | 84 | tls_client_cert_key_password=kwargs.get("_tls_client_cert_key_password"), |
75 | 85 | ) |
76 | 86 |
|
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 | + ) |
87 | 107 |
|
88 | 108 | self.protocol_version = None |
89 | 109 |
|
|
0 commit comments