sunholo 0.128.0__py3-none-any.whl → 0.129.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ from .custom_logging import setup_logging, GoogleCloudLogging
2
+
3
+ class TracedGoogleCloudLogging(GoogleCloudLogging):
4
+ """Extends GoogleCloudLogging with trace ID functionality."""
5
+
6
+ def __init__(self, project_id=None, log_level=None, logger_name=None, trace_id=None):
7
+ super().__init__(project_id, log_level, logger_name)
8
+ self.trace_id = trace_id
9
+
10
+ def update_trace_id(self, trace_id):
11
+ """Update the trace ID to be included in all logs."""
12
+ self.trace_id = trace_id
13
+
14
+ def _get_trace_prefix(self):
15
+ """Get the trace prefix if a trace ID is set."""
16
+ return f"aitana-{self.trace_id} " if self.trace_id else ""
17
+
18
+ def structured_log(self, log_text=None, log_struct=None, logger_name=None, severity="INFO"):
19
+ """Override to add trace ID to logs."""
20
+ if log_text and self.trace_id:
21
+ log_text = f"{self._get_trace_prefix()}{log_text}"
22
+
23
+ if log_struct and self.trace_id:
24
+ if isinstance(log_struct, dict):
25
+ log_struct = {**log_struct, "trace_id": self.trace_id}
26
+
27
+ # Call the parent method with the modified parameters
28
+ super().structured_log(log_text, log_struct, logger_name, severity)
29
+
30
+ def setup_traced_logging(logger_name=None, log_level=None, project_id=None, trace_id=None):
31
+ """Sets up traced logging that includes a trace ID in all logs."""
32
+ # First get the base logger from the original setup_logging
33
+ base_logger = setup_logging(logger_name, log_level, project_id)
34
+
35
+ # If it's a GoogleCloudLogging instance, wrap it with our traced version
36
+ if isinstance(base_logger, GoogleCloudLogging):
37
+ traced_logger = TracedGoogleCloudLogging(
38
+ project_id=base_logger.project_id,
39
+ log_level=base_logger.log_level,
40
+ logger_name=base_logger.logger_name,
41
+ trace_id=trace_id
42
+ )
43
+ traced_logger.client = base_logger.client # Reuse the client
44
+ return traced_logger
45
+
46
+ # For standard Python logging, we can add a filter
47
+ import logging
48
+ class TraceFilter(logging.Filter):
49
+ def __init__(self, trace_id=None):
50
+ super().__init__()
51
+ self.trace_id = trace_id
52
+
53
+ def update_trace_id(self, trace_id):
54
+ self.trace_id = trace_id
55
+
56
+ def filter(self, record):
57
+ if self.trace_id:
58
+ prefix = f"aitana-{self.trace_id} "
59
+ if not record.msg.startswith(prefix):
60
+ record.msg = f"{prefix}{record.msg}"
61
+ return True
62
+
63
+ # Add the trace filter to the logger
64
+ trace_filter = TraceFilter(trace_id)
65
+ base_logger.addFilter(trace_filter)
66
+
67
+ # Add the update method to the standard logger
68
+ base_logger.update_trace_id = trace_filter.update_trace_id
69
+
70
+ return base_logger
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sunholo
3
- Version: 0.128.0
3
+ Version: 0.129.0
4
4
  Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
5
5
  Author-email: Holosun ApS <multivac@sunholo.com>
6
6
  License: Apache License, Version 2.0
@@ -1,6 +1,7 @@
1
1
  sunholo/__init__.py,sha256=InRbX4V0-qdNHo9zYH3GEye7ASLR6LX8-SMvPV4Jsaw,1212
2
2
  sunholo/custom_logging.py,sha256=YfIN1oP3dOEkkYkyRBU8BGS3uJFGwUDsFCl8mIVbwvE,12225
3
3
  sunholo/langchain_types.py,sha256=uZ4zvgej_f7pLqjtu4YP7qMC_eZD5ym_5x4pyvA1Ih4,1834
4
+ sunholo/traced_logging.py,sha256=TaAK9gFQ63h700dXfCK-nLcyMvh00N-oZ-xlz4VAZ_4,2891
4
5
  sunholo/agents/__init__.py,sha256=X2I3pPkGeKWjc3d0QgSpkTyqD8J8JtrEWqwrumf1MMc,391
5
6
  sunholo/agents/chat_history.py,sha256=Gph_CdlP2otYnNdR1q1Umyyyvcad2F6K3LxU5yBQ9l0,5387
6
7
  sunholo/agents/dispatch_to_qa.py,sha256=NHihwAoCJ5_Lk11e_jZnucVUGQyZHCB-YpkfMHBCpQk,8882
@@ -168,9 +169,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
168
169
  sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
169
170
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
170
171
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
171
- sunholo-0.128.0.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
172
- sunholo-0.128.0.dist-info/METADATA,sha256=J6Zt0Y-mKxILQKfONCunRsPBV5bXDHBrnI5lt09dNpQ,10084
173
- sunholo-0.128.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
174
- sunholo-0.128.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
175
- sunholo-0.128.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
176
- sunholo-0.128.0.dist-info/RECORD,,
172
+ sunholo-0.129.0.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
173
+ sunholo-0.129.0.dist-info/METADATA,sha256=57vcuIcATCDaw7YigDz2bXfPqGp3PBSToaTLJLIiJRo,10084
174
+ sunholo-0.129.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
175
+ sunholo-0.129.0.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
176
+ sunholo-0.129.0.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
177
+ sunholo-0.129.0.dist-info/RECORD,,