@@ -367,27 +367,12 @@ def initialize_telemetry_client(
367367 """Initialize a telemetry client for a specific connection if telemetry is enabled"""
368368 try :
369369
370- print (
371- "\n WAITING: Initializing telemetry client: %s" ,
372- session_id_hex ,
373- flush = True ,
374- )
375370 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- )
387371
372+ TelemetryClientFactory ._initialize ()
388373 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" ,
391376 session_id_hex ,
392377 flush = True ,
393378 )
@@ -396,7 +381,6 @@ def initialize_telemetry_client(
396381 session_id_hex ,
397382 )
398383 if telemetry_enabled :
399- print ("\n Telemetry enabled: %s" , session_id_hex , flush = True )
400384 TelemetryClientFactory ._clients [
401385 session_id_hex
402386 ] = TelemetryClient (
@@ -406,41 +390,16 @@ def initialize_telemetry_client(
406390 host_url = host_url ,
407391 executor = TelemetryClientFactory ._executor ,
408392 )
409- print (
410- "\n Telemetry client initialized: %s" ,
411- session_id_hex ,
412- flush = True ,
413- )
414393 else :
415- print (
416- "\n Telemetry disabled: %s" , session_id_hex , flush = True
417- )
394+ logger .debug ("Telemetry disabled: %s" , session_id_hex )
418395 TelemetryClientFactory ._clients [
419396 session_id_hex
420397 ] = 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
425400 )
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+
437402 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- )
444403 logger .debug ("Failed to initialize telemetry client: %s" , e )
445404 # Fallback to NoopTelemetryClient to ensure connection doesn't fail
446405 TelemetryClientFactory ._clients [session_id_hex ] = NoopTelemetryClient ()
@@ -464,19 +423,12 @@ def get_telemetry_client(session_id_hex):
464423 @staticmethod
465424 def close (session_id_hex ):
466425 """Close and remove the telemetry client for a specific connection"""
467- print ("\n WAITING: Closing telemetry client: %s" , session_id_hex , flush = True )
468426 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 :
480432 logger .debug (
481433 "Removing telemetry client for connection %s" , session_id_hex
482434 )
@@ -488,16 +440,6 @@ def close(session_id_hex):
488440 logger .debug (
489441 "No more telemetry clients, shutting down thread pool executor"
490442 )
491- print (
492- "\n SHUTDOWN: Shutting down thread pool executor: %s" ,
493- session_id_hex ,
494- flush = True ,
495- )
496443 TelemetryClientFactory ._executor .shutdown (wait = True )
497444 TelemetryClientFactory ._executor = None
498445 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