1919 set_debug_enabled (True )
2020
2121logger = get_logger ("agent" )
22- logger .info ("Superstream Agent initialized with environment variables: {}" , _ENV_VARS )
23- if is_disabled ():
24- logger .warn ("Superstream functionality disabled via SUPERSTREAM_DISABLED" )
2522
2623# Preserve reference to built-in import function
2724_original_import = builtins .__import__
@@ -47,7 +44,12 @@ def _patch_module(module_name: str) -> None:
4744 # Check if Producer exists before patching
4845 confluent_module = sys .modules ["confluent_kafka" ]
4946 if hasattr (confluent_module , "Producer" ):
50- patch_confluent (confluent_module )
47+ # Additional check to ensure we can safely patch
48+ try :
49+ patch_confluent (confluent_module )
50+ except Exception as patch_exc :
51+ logger .error ("[ERR-003] Failed to patch confluent_kafka Producer: {}" , patch_exc )
52+ # Don't re-raise, just log the error
5153 except Exception as exc :
5254 logger .error ("[ERR-001] Failed to patch {}: {}" , module_name , exc )
5355
@@ -93,6 +95,12 @@ def initialize():
9395 2. Schedules patching of any pre-imported modules
9496 3. Starts the heartbeat thread
9597 """
98+
99+ # Log initialization message
100+ logger .info ("Superstream Agent initialized with environment variables: {}" , _ENV_VARS )
101+ if is_disabled ():
102+ logger .warn ("Superstream functionality disabled via SUPERSTREAM_DISABLED" )
103+
96104 if is_disabled ():
97105 return
98106
0 commit comments