Skip to content

events

dandy.recorder.events

EventType

Bases: StrEnum

RUN = 'run' class-attribute instance-attribute

RETRY = 'retry' class-attribute instance-attribute

REQUEST = 'request' class-attribute instance-attribute

RESPONSE = 'response' class-attribute instance-attribute

RESULT = 'result' class-attribute instance-attribute

SUCCESS = 'success' class-attribute instance-attribute

WARNING = 'warning' class-attribute instance-attribute

FAILURE = 'failure' class-attribute instance-attribute

OTHER = 'other' class-attribute instance-attribute

EventAttribute

Bases: BaseModel

key instance-attribute

value instance-attribute

is_dropdown = False class-attribute instance-attribute

is_card = False class-attribute instance-attribute

is_base64_image = False class-attribute instance-attribute

Event

Bases: BaseModel

id instance-attribute

object_name instance-attribute

callable_name instance-attribute

type instance-attribute

attributes = Field(default_factory=list) class-attribute instance-attribute

start_time = Field(default_factory=perf_counter) class-attribute instance-attribute

token_usage = 0 class-attribute instance-attribute

run_time_seconds = 0.0 class-attribute instance-attribute

complete_run_time_seconds = 0.0 class-attribute instance-attribute

model_post_init

Source code in dandy/recorder/events.py
def model_post_init(self, __context: Any, /) -> None:
    if settings.DEBUG:
        logging.debug(str(self))

calculate_run_time

Source code in dandy/recorder/events.py
def calculate_run_time(self, pre_event: Self) -> None:
    self.run_time_seconds = self.start_time - pre_event.start_time
    self.complete_run_time_seconds = (
        pre_event.complete_run_time_seconds + self.run_time_seconds
    )

add_attribute

Source code in dandy/recorder/events.py
def add_attribute(
    self,
    key: str,
    value: Any,
    is_dropdown: bool = False,
    is_card: bool = False,
    is_base64_image: bool = False,
) -> Self:
    self.attributes.append(
        EventAttribute(
            key=key,
            value=value,
            is_dropdown=is_dropdown,
            is_card=is_card,
            is_base64_image=is_base64_image,
        )
    )

    return self

EventStore

Bases: BaseModel

events = Field(default_factory=list) class-attribute instance-attribute

event_count property

events_total_run_time property

events_total_token_usage property

add_event

Source code in dandy/recorder/events.py
def add_event(self, event: Event) -> Event:
    self.events.append(event)
    self._calculate_event_run_times()

    return event