Skip to content

Commit 0f776c5

Browse files
SNOW-2171791: Add platform telemetry (#2387)
Co-authored-by: Maxim Mishchenko <[email protected]>
1 parent 3f9edc2 commit 0f776c5

File tree

11 files changed

+1005
-50
lines changed

11 files changed

+1005
-50
lines changed

src/snowflake/connector/auth/_auth.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
PYTHON_CONNECTOR_USER_AGENT,
5353
ReauthenticationRequest,
5454
)
55+
from ..platform_detection import detect_platforms
5556
from ..sqlstate import SQLSTATE_CONNECTION_WAS_NOT_ESTABLISHED
5657
from ..token_cache import TokenCache, TokenKey, TokenType
5758
from ..version import VERSION
@@ -101,6 +102,7 @@ def base_auth_data(
101102
login_timeout: int | None = None,
102103
network_timeout: int | None = None,
103104
socket_timeout: int | None = None,
105+
platform_detection_timeout_seconds: float | None = None,
104106
):
105107
return {
106108
"data": {
@@ -122,6 +124,9 @@ def base_auth_data(
122124
"LOGIN_TIMEOUT": login_timeout,
123125
"NETWORK_TIMEOUT": network_timeout,
124126
"SOCKET_TIMEOUT": socket_timeout,
127+
"PLATFORM": detect_platforms(
128+
platform_detection_timeout_seconds=platform_detection_timeout_seconds
129+
),
125130
},
126131
},
127132
}
@@ -177,6 +182,7 @@ def authenticate(
177182
self._rest._connection.login_timeout,
178183
self._rest._connection._network_timeout,
179184
self._rest._connection._socket_timeout,
185+
self._rest._connection._platform_detection_timeout_seconds,
180186
)
181187

182188
body = copy.deepcopy(body_template)

src/snowflake/connector/connection.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ def _get_private_bytes_from_file(
197197
), # network timeout (infinite by default)
198198
"socket_timeout": (None, (type(None), int)),
199199
"external_browser_timeout": (120, int),
200+
"platform_detection_timeout_seconds": (
201+
None,
202+
(type(None), float),
203+
), # Platform detection timeout for CSP metadata endpoints
200204
"backoff_policy": (DEFAULT_BACKOFF_POLICY, Callable),
201205
"passcode_in_password": (False, bool), # Snowflake MFA
202206
"passcode": (None, (type(None), str)), # Snowflake MFA
@@ -704,6 +708,14 @@ def client_session_keep_alive_heartbeat_frequency(self, value) -> None:
704708
self._client_session_keep_alive_heartbeat_frequency = value
705709
self._validate_client_session_keep_alive_heartbeat_frequency()
706710

711+
@property
712+
def platform_detection_timeout_seconds(self) -> float | None:
713+
return self._platform_detection_timeout_seconds
714+
715+
@platform_detection_timeout_seconds.setter
716+
def platform_detection_timeout_seconds(self, value) -> None:
717+
self._platform_detection_timeout_seconds = value
718+
707719
@property
708720
def client_prefetch_threads(self) -> int:
709721
return (

0 commit comments

Comments
 (0)