@@ -367,27 +367,12 @@ def initialize_telemetry_client(
367
367
"""Initialize a telemetry client for a specific connection if telemetry is enabled"""
368
368
try :
369
369
370
- print (
371
- "\n WAITING: Initializing telemetry client: %s" ,
372
- session_id_hex ,
373
- flush = True ,
374
- )
375
370
with TelemetryClientFactory ._lock :
376
- print (
377
- "\n ACQUIRED: Initializing telemetry client, got lock: %s" ,
378
- session_id_hex ,
379
- flush = True ,
380
- )
381
- TelemetryClientFactory ._initialize ()
382
- print (
383
- "\n TelemetryClientFactory initialized: %s" ,
384
- session_id_hex ,
385
- flush = True ,
386
- )
387
371
372
+ TelemetryClientFactory ._initialize ()
388
373
if session_id_hex not in TelemetryClientFactory ._clients :
389
- print (
390
- "\n Session ID not in clients: %s" ,
374
+ logger . debug (
375
+ "Session ID not in clients: %s" ,
391
376
session_id_hex ,
392
377
flush = True ,
393
378
)
@@ -396,7 +381,6 @@ def initialize_telemetry_client(
396
381
session_id_hex ,
397
382
)
398
383
if telemetry_enabled :
399
- print ("\n Telemetry enabled: %s" , session_id_hex , flush = True )
400
384
TelemetryClientFactory ._clients [
401
385
session_id_hex
402
386
] = TelemetryClient (
@@ -406,41 +390,16 @@ def initialize_telemetry_client(
406
390
host_url = host_url ,
407
391
executor = TelemetryClientFactory ._executor ,
408
392
)
409
- print (
410
- "\n Telemetry client initialized: %s" ,
411
- session_id_hex ,
412
- flush = True ,
413
- )
414
393
else :
415
- print (
416
- "\n Telemetry disabled: %s" , session_id_hex , flush = True
417
- )
394
+ logger .debug ("Telemetry disabled: %s" , session_id_hex )
418
395
TelemetryClientFactory ._clients [
419
396
session_id_hex
420
397
] = NoopTelemetryClient ()
421
- print (
422
- "\n Noop Telemetry client initialized: %s" ,
423
- session_id_hex ,
424
- flush = True ,
398
+ logger .debug (
399
+ "Noop Telemetry client initialized: %s" , session_id_hex
425
400
)
426
- else :
427
- print (
428
- "\n Session ID already in clients: %s" ,
429
- session_id_hex ,
430
- flush = True ,
431
- )
432
- print (
433
- "\n RELEASED: Telemetry client initialized: %s" ,
434
- session_id_hex ,
435
- flush = True ,
436
- )
401
+
437
402
except Exception as e :
438
- print (
439
- "\n ERROR: Failed to initialize telemetry client: %s due to %s" ,
440
- session_id_hex ,
441
- e ,
442
- flush = True ,
443
- )
444
403
logger .debug ("Failed to initialize telemetry client: %s" , e )
445
404
# Fallback to NoopTelemetryClient to ensure connection doesn't fail
446
405
TelemetryClientFactory ._clients [session_id_hex ] = NoopTelemetryClient ()
@@ -464,19 +423,12 @@ def get_telemetry_client(session_id_hex):
464
423
@staticmethod
465
424
def close (session_id_hex ):
466
425
"""Close and remove the telemetry client for a specific connection"""
467
- print ("\n WAITING: Closing telemetry client: %s" , session_id_hex , flush = True )
468
426
with TelemetryClientFactory ._lock :
469
- print (
470
- "\n ACQUIRED: Closing telemetry client, got lock: %s" ,
471
- session_id_hex ,
472
- flush = True ,
473
- )
474
- # if (
475
- # telemetry_client := TelemetryClientFactory._clients.pop(
476
- # session_id_hex, None
477
- # )
478
- # ) is not None:
479
- if session_id_hex in TelemetryClientFactory ._clients :
427
+ if (
428
+ telemetry_client := TelemetryClientFactory ._clients .pop (
429
+ session_id_hex , None
430
+ )
431
+ ) is not None :
480
432
logger .debug (
481
433
"Removing telemetry client for connection %s" , session_id_hex
482
434
)
@@ -488,16 +440,6 @@ def close(session_id_hex):
488
440
logger .debug (
489
441
"No more telemetry clients, shutting down thread pool executor"
490
442
)
491
- print (
492
- "\n SHUTDOWN: Shutting down thread pool executor: %s" ,
493
- session_id_hex ,
494
- flush = True ,
495
- )
496
443
TelemetryClientFactory ._executor .shutdown (wait = True )
497
444
TelemetryClientFactory ._executor = None
498
445
TelemetryClientFactory ._initialized = False
499
- print (
500
- "\n RELEASED: Thread pool executor shut down: %s" ,
501
- session_id_hex ,
502
- flush = True ,
503
- )
0 commit comments