Skip to content

trulens.core.otel.client_hooks.journal

trulens.core.otel.client_hooks.journal

Crash-tolerant local event journal for short-lived hook processes.

Classes

EventJournal

Persist and correlate hook events across independent processes.

Functions
append
append(event: HookEvent) -> Tuple[str, bool]

Append an event and return its correlated turn and terminal state.

get_turn
get_turn(
    client: str, conversation_id: str, turn_id: str
) -> List[HookEvent]

Read all events for one turn in observation order.

conversations
conversations() -> List[Tuple[str, str]]

Discover client/conversation pairs represented in the journal.

has_exportable_turns
has_exportable_turns(
    *, stale_after: timedelta = timedelta(hours=24)
) -> bool

Return whether any complete, stale, or retryable turn can be exported.

next_retry_delay
next_retry_delay() -> Optional[float]

Return seconds until the earliest retry or claim lease expires.

status
status() -> Dict[str, Any]

Summarize pending, claimed, and retrying journal turns.

mark_exported
mark_exported(
    client: str, conversation_id: str, turn_id: str
) -> None

Mark a turn exported after its complete span batch succeeds.

claim_pending_turns
claim_pending_turns(
    client: str,
    conversation_id: str,
    *,
    stale_after: timedelta = timedelta(hours=24),
    lease_for: timedelta = timedelta(minutes=5)
) -> List[str]

Atomically claim complete or stale turns for one exporter.

pending_turns
pending_turns(
    client: str,
    conversation_id: str,
    *,
    stale_after: timedelta = timedelta(hours=24)
) -> List[str]

Return complete or stale unexported turns without claiming them.

release_claim
release_claim(
    client: str,
    conversation_id: str,
    turn_id: str,
    *,
    failed: bool
) -> None

Release an export claim, applying bounded backoff after failures.

Functions

default_journal_dir

default_journal_dir() -> Path

Return the configured or platform-neutral journal directory.

export_lease_from_environment

export_lease_from_environment() -> timedelta

Return the configured bounded export claim duration.