19
19
set_debug_enabled (True )
20
20
21
21
logger = 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" )
25
22
26
23
# Preserve reference to built-in import function
27
24
_original_import = builtins .__import__
@@ -47,7 +44,12 @@ def _patch_module(module_name: str) -> None:
47
44
# Check if Producer exists before patching
48
45
confluent_module = sys .modules ["confluent_kafka" ]
49
46
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
51
53
except Exception as exc :
52
54
logger .error ("[ERR-001] Failed to patch {}: {}" , module_name , exc )
53
55
@@ -93,6 +95,12 @@ def initialize():
93
95
2. Schedules patching of any pre-imported modules
94
96
3. Starts the heartbeat thread
95
97
"""
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
+
96
104
if is_disabled ():
97
105
return
98
106
0 commit comments