pub struct ExecutionUsage {
pub execution_id: ExecutionId,
pub tenant_id: TenantId,
pub steps: AtomicU32,
pub input_tokens: AtomicU32,
pub output_tokens: AtomicU32,
pub started_at: Instant,
pub last_activity: RwLock<Instant>,
pub discovered_steps: AtomicU32,
pub discovery_depth: AtomicU32,
pub max_discovery_depth_reached: AtomicU32,
pub cost_cents: AtomicU64,
}Expand description
Tracks resource usage for a single execution
Fields§
§execution_id: ExecutionIdExecution ID
tenant_id: TenantIdTenant ID
steps: AtomicU32Number of steps executed
input_tokens: AtomicU32Total input tokens consumed
output_tokens: AtomicU32Total output tokens consumed
started_at: InstantWall clock start time
last_activity: RwLock<Instant>Last activity timestamp
discovered_steps: AtomicU32Number of dynamically discovered steps (StepSource::Discovered)
discovery_depth: AtomicU32Current discovery chain depth (how deep in the discovery tree)
max_discovery_depth_reached: AtomicU32Maximum discovery depth reached during execution
cost_cents: AtomicU64Cumulative cost in cents (USD * 100 for integer precision)
Implementations§
Source§impl ExecutionUsage
impl ExecutionUsage
Sourcepub fn new(execution_id: ExecutionId, tenant_id: TenantId) -> Self
pub fn new(execution_id: ExecutionId, tenant_id: TenantId) -> Self
Create a new usage tracker for an execution
Sourcepub fn record_step(&self)
pub fn record_step(&self)
Record step execution
Sourcepub fn record_discovered_step(&self)
pub fn record_discovered_step(&self)
Record a discovered step (dynamically added to DAG)
Sourcepub fn record_tokens(&self, input: u32, output: u32)
pub fn record_tokens(&self, input: u32, output: u32)
Record token usage
Sourcepub fn record_cost_usd(&self, cost_usd: f64)
pub fn record_cost_usd(&self, cost_usd: f64)
Record cost in USD (converted to cents for storage)
Sourcepub fn push_discovery_depth(&self)
pub fn push_discovery_depth(&self)
Push discovery depth (entering a discovered step)
Sourcepub fn pop_discovery_depth(&self)
pub fn pop_discovery_depth(&self)
Pop discovery depth (exiting a discovered step)
Sourcepub fn step_count(&self) -> u32
pub fn step_count(&self) -> u32
Get current step count
Sourcepub fn discovered_step_count(&self) -> u32
pub fn discovered_step_count(&self) -> u32
Get discovered step count
Sourcepub fn current_discovery_depth(&self) -> u32
pub fn current_discovery_depth(&self) -> u32
Get current discovery depth
Sourcepub fn total_tokens(&self) -> u32
pub fn total_tokens(&self) -> u32
Get total token count
Sourcepub fn wall_time_ms(&self) -> u64
pub fn wall_time_ms(&self) -> u64
Get wall time in milliseconds
Sourcepub async fn idle_duration(&self) -> Duration
pub async fn idle_duration(&self) -> Duration
Get idle duration (time since last activity)
Sourcepub async fn idle_seconds(&self) -> u64
pub async fn idle_seconds(&self) -> u64
Get idle duration in seconds