roboto.domain.actions.stats
Action statistics functionality for retrieving invocation metrics.
Module Contents
ActionStatsRecord
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 AnyAttributes
ActionStatsRecord.action_name
Name of the action. Action names are unique within an organization.
ActionStatsRecord.completed_count
Number of invocations that completed successfully during the time period.
ActionStatsRecord.fail_count
Number of invocations that failed during the time period.
ActionStatsRecord.queued_count
Number of invocations that are currently queued or in progress during the time period.
get_action_stats()
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.Start of the time period (inclusive) for which to retrieve statistics.
end_time datetime.End of the time period (exclusive) for which to retrieve statistics.
roboto_client Optional[roboto.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
The caller is not authorized to access statistics for the specified organization.
Invalid time range or organization ID provided.
Usage
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")