Skip to content

Commit 5270a6c

Browse files
committed
removed default arg for batch size
Signed-off-by: Sai Shree Pradhan <[email protected]>
1 parent 8517ce8 commit 5270a6c

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

src/databricks/sql/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ def read(self) -> Optional[OAuthToken]:
251251
self.telemetry_enabled = (
252252
self.client_telemetry_enabled and self.server_telemetry_enabled
253253
)
254-
self.telemetry_batch_size = kwargs.get("telemetry_batch_size")
254+
self.telemetry_batch_size = kwargs.get(
255+
"telemetry_batch_size", TelemetryClientFactory.DEFAULT_BATCH_SIZE
256+
)
255257

256258
user_agent_entry = kwargs.get("user_agent_entry")
257259
if user_agent_entry is None:

src/databricks/sql/telemetry/telemetry_client.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,22 +132,18 @@ class TelemetryClient(BaseTelemetryClient):
132132
TELEMETRY_AUTHENTICATED_PATH = "/telemetry-ext"
133133
TELEMETRY_UNAUTHENTICATED_PATH = "/telemetry-unauth"
134134

135-
DEFAULT_BATCH_SIZE = 100
136-
137135
def __init__(
138136
self,
139137
telemetry_enabled,
140138
session_id_hex,
141139
auth_provider,
142140
host_url,
143141
executor,
144-
batch_size=None,
142+
batch_size,
145143
):
146144
logger.debug("Initializing TelemetryClient for connection: %s", session_id_hex)
147145
self._telemetry_enabled = telemetry_enabled
148-
self._batch_size = (
149-
batch_size if batch_size is not None else self.DEFAULT_BATCH_SIZE
150-
)
146+
self._batch_size = batch_size
151147
self._session_id_hex = session_id_hex
152148
self._auth_provider = auth_provider
153149
self._user_agent = None
@@ -332,6 +328,8 @@ class TelemetryClientFactory:
332328
_flush_event = threading.Event()
333329
_flush_interval_seconds = 90
334330

331+
DEFAULT_BATCH_SIZE = 100
332+
335333
@classmethod
336334
def _initialize(cls):
337335
"""Initialize the factory if not already initialized"""
@@ -403,7 +401,7 @@ def initialize_telemetry_client(
403401
session_id_hex,
404402
auth_provider,
405403
host_url,
406-
batch_size=None,
404+
batch_size,
407405
):
408406
"""Initialize a telemetry client for a specific connection if telemetry is enabled"""
409407
try:

tests/unit/test_telemetry.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def mock_telemetry_client():
3131
auth_provider=auth_provider,
3232
host_url="test-host.com",
3333
executor=executor,
34+
batch_size=TelemetryClientFactory.DEFAULT_BATCH_SIZE
3435
)
3536

3637

@@ -208,7 +209,8 @@ def test_client_lifecycle_flow(self):
208209
telemetry_enabled=True,
209210
session_id_hex=session_id_hex,
210211
auth_provider=auth_provider,
211-
host_url="test-host.com"
212+
host_url="test-host.com",
213+
batch_size=TelemetryClientFactory.DEFAULT_BATCH_SIZE
212214
)
213215

214216
client = TelemetryClientFactory.get_telemetry_client(session_id_hex)
@@ -232,7 +234,8 @@ def test_disabled_telemetry_flow(self):
232234
telemetry_enabled=False,
233235
session_id_hex=session_id_hex,
234236
auth_provider=None,
235-
host_url="test-host.com"
237+
host_url="test-host.com",
238+
batch_size=TelemetryClientFactory.DEFAULT_BATCH_SIZE
236239
)
237240

238241
client = TelemetryClientFactory.get_telemetry_client(session_id_hex)
@@ -249,7 +252,8 @@ def test_factory_error_handling(self):
249252
telemetry_enabled=True,
250253
session_id_hex=session_id,
251254
auth_provider=AccessTokenAuthProvider("token"),
252-
host_url="test-host.com"
255+
host_url="test-host.com",
256+
batch_size=TelemetryClientFactory.DEFAULT_BATCH_SIZE
253257
)
254258

255259
# Should fall back to NoopTelemetryClient
@@ -267,7 +271,8 @@ def test_factory_shutdown_flow(self):
267271
telemetry_enabled=True,
268272
session_id_hex=session,
269273
auth_provider=AccessTokenAuthProvider("token"),
270-
host_url="test-host.com"
274+
host_url="test-host.com",
275+
batch_size=TelemetryClientFactory.DEFAULT_BATCH_SIZE
271276
)
272277

273278
# Factory should be initialized

0 commit comments

Comments
 (0)