roboto.domain.actions.stats#
Action statistics functionality for retrieving invocation metrics.
Module Contents#
- class roboto.domain.actions.stats.ActionStatsRecord(/, **data)#
Bases:
pydantic.BaseModel
Statistical summary of action invocations for a specific action within a time period.
This model represents aggregated invocation counts for a single action, broken down by completion status (completed, failed, queued).
- Parameters:
data (Any)
- action_name: str#
Name of the action. Action names are unique within an organization.
- action_org_id: str#
Organization ID that owns the action.
- completed_count: int#
Number of invocations that completed successfully during the time period.
- fail_count: int#
Number of invocations that failed during the time period.
- queued_count: int#
Number of invocations that are currently queued or in progress during the time period.
- roboto.domain.actions.stats.get_action_stats(start_time, end_time, roboto_client=None, org_id=None)#
Retrieve action invocation statistics for all actions in an organization.
Fetches aggregated statistics showing invocation counts by status for each action within the specified organization and time range. This provides a high-level view of action usage and success rates across the organization.
- Parameters:
org_id (Optional[str]) – Organization ID to retrieve statistics for.
start_time (datetime.datetime) – Start of the time period (inclusive) for which to retrieve statistics.
end_time (datetime.datetime) – End of the time period (exclusive) for which to retrieve statistics.
roboto_client (Optional[roboto.http.RobotoClient]) – HTTP client for making API requests. If not provided, uses the default client configuration.
- Returns:
List of ActionStatsRecord objects, one for each action that had invocations during the specified time period. Actions with no invocations are not included.
- Raises:
RobotoUnauthorizedException – The caller is not authorized to access statistics for the specified organization.
RobotoInvalidRequestException – Invalid time range or organization ID provided.
- Return type:
list[ActionStatsRecord]
Examples
Get statistics for the last 24 hours:
>>> import datetime >>> from roboto.domain.actions.stats import get_action_stats >>> end_time = datetime.datetime.now() >>> start_time = end_time - datetime.timedelta(days=1) >>> stats = get_action_stats(start_time, end_time, org_id="og_1234567890abcdef") >>> for stat in stats: ... print(f"{stat.action_name}: {stat.completed_count} completed, {stat.fail_count} failed")