Skip to content

armgit / burr

Public Imported from GitHub
0

Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.

Adds do_log_attribute hooks

elijahbenizzy04b9154641a9
diff --git a/burr/lifecycle/base.py b/burr/lifecycle/base.py
index 897f41be..39bfa2c9 100644
--- a/burr/lifecycle/base.py
+++ b/burr/lifecycle/base.py
@@ -191,6 +191,44 @@ class PreStartSpanHookAsync(abc.ABC):
pass
[email protected]_hook("do_log_attributes")
+class DoLogAttributeHook(abc.ABC):
+ """Hook that is responsible for logging attributes,
+ called by the tracer."""
+
+ @abc.abstractmethod
+ def do_log_attributes(
+ self,
+ *,
+ attributes: Dict[str, Any],
+ action: str,
+ action_sequence_id: int,
+ span: Optional["ActionSpan"],
+ tags: dict,
+ **future_kwargs: Any,
+ ):
+ pass
+
+
[email protected]_hook("do_log_attributes")
+class DoLogAttributeHookAsync(abc.ABC):
+ """Hook that runs after a span is ended in the tracing API.
+ This can be either a context manager or a logger."""
+
+ @abc.abstractmethod
+ async def do_log_attributes(
+ self,
+ *,
+ attributes: Dict[str, Any],
+ action: str,
+ action_sequence_id: int,
+ span: "ActionSpan",
+ tags: dict,
+ **future_kwargs: Any,
+ ):
+ pass
+
+
@lifecycle.base_hook("post_end_span")
class PostEndSpanHook(abc.ABC):
"""Hook that runs after a span is ended in the tracing API.