Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.
Python aiburrchatbot-frameworkdagsgenerative-aigraphshacktoberfestllmopsllmsmlopspersistent-data-structurestate-machinestate-managementvisibility
Adds attribute logging to s3 tracker
elijahbenizzye0bc9f5f35c7
diff --git a/burr/integrations/opentelemetry.py b/burr/integrations/opentelemetry.pyindex f5804722..fb9fb59c 100644--- a/burr/integrations/opentelemetry.py+++ b/burr/integrations/opentelemetry.py@@ -427,6 +427,7 @@ class BurrTrackingSpanProcessor(SpanProcessor):span=cached_span.action_span,tags={}, # TODO -- logapp_id=cached_span.app_id,+ partition_key=cached_span.partition_key,)diff --git a/burr/lifecycle/base.py b/burr/lifecycle/base.pyindex cca891ba..d256cf88 100644--- a/burr/lifecycle/base.py+++ b/burr/lifecycle/base.py@@ -206,6 +206,8 @@ class DoLogAttributeHook(abc.ABC):action_sequence_id: int,span: Optional["ActionSpan"],tags: dict,+ app_id: str,+ partition_key: Optional[str],**future_kwargs: Any,):pass@@ -225,6 +227,8 @@ class DoLogAttributeHookAsync(abc.ABC):action_sequence_id: int,span: "ActionSpan",tags: dict,+ app_id: str,+ partition_key: Optional[str],**future_kwargs: Any,):passdiff --git a/burr/tracking/common/models.py b/burr/tracking/common/models.pyindex 1f4622ab..357ef0d2 100644--- a/burr/tracking/common/models.py+++ b/burr/tracking/common/models.py@@ -189,6 +189,8 @@ class EndSpanModel(IdentifyingModel):@propertydef sequence_id(self) -> int:+ # so we have full backwards compatibility+ # the server likes them all to be called sequence_idreturn self.action_sequence_id@@ -203,3 +205,8 @@ class AttributeModel(IdentifyingModel):value: Union[dict, str, int, float, bool, list, None]tags: Dict[str, str]type: str = "attribute"++ @property+ def sequence_id(self) -> int:+ # Ditto with the above+ return self.action_sequence_iddiff --git a/burr/tracking/s3client.py b/burr/tracking/s3client.pyindex dfa86d86..79906745 100644--- a/burr/tracking/s3client.py+++ b/burr/tracking/s3client.py@@ -19,6 +19,7 @@ from burr.tracking.base import SyncTrackingClientfrom burr.tracking.common.models import (ApplicationMetadataModel,ApplicationModel,+ AttributeModel,BeginEntryModel,BeginSpanModel,EndEntryModel,@@ -84,7 +85,7 @@ def _allowed_project_name(project_name: str, on_windows: bool) -> bool:return bool(re.match(pattern, project_name))-EventType = Union[BeginEntryModel, EndEntryModel, BeginSpanModel, EndSpanModel]+EventType = Union[BeginEntryModel, EndEntryModel, BeginSpanModel, EndSpanModel, AttributeModel]def unique_ordered_prefix() -> str:@@ -122,12 +123,22 @@ class S3TrackingClient(SyncTrackingClient):action: str,action_sequence_id: int,span: Optional["ActionSpan"],+ app_id: str,+ partition_key: Optional[str],tags: dict,**future_kwargs: Any,):# TODO -- log attributes to s3 as well# Coming up shortly- pass+ for attribute_name, attribute in attributes.items():+ attribute_model = AttributeModel(+ key=attribute_name,+ action_sequence_id=action_sequence_id,+ span_id=span.uid if span is not None else None,+ value=serde.serialize(attribute, **self.serde_kwargs),+ tags=tags,+ )+ self.submit_log_event(attribute_model, app_id=app_id, partition_key=partition_key)def __init__(self,@@ -305,7 +316,6 @@ class S3TrackingClient(SyncTrackingClient):else "None",},)- # TODO -- log parent relationshipdef pre_run_step(self,diff --git a/burr/visibility/tracing.py b/burr/visibility/tracing.pyindex 439a78a2..b0c72989 100644--- a/burr/visibility/tracing.py+++ b/burr/visibility/tracing.py@@ -232,6 +232,8 @@ class ActionSpanTracer(AbstractContextManager, AbstractAsyncContextManager):action=self.action,action_sequence_id=self.action_sequence_id,span=self.context_var.get(),+ app_id=self.app_id,+ partition_key=self.partition_key,tags={}, # TODO -- add tags)