Skip to main content

ExecutionUsage

Struct ExecutionUsage 

Source
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: ExecutionId

Execution ID

§tenant_id: TenantId

Tenant ID

§steps: AtomicU32

Number of steps executed

§input_tokens: AtomicU32

Total input tokens consumed

§output_tokens: AtomicU32

Total output tokens consumed

§started_at: Instant

Wall clock start time

§last_activity: RwLock<Instant>

Last activity timestamp

§discovered_steps: AtomicU32

Number of dynamically discovered steps (StepSource::Discovered)

§discovery_depth: AtomicU32

Current discovery chain depth (how deep in the discovery tree)

§max_discovery_depth_reached: AtomicU32

Maximum discovery depth reached during execution

§cost_cents: AtomicU64

Cumulative cost in cents (USD * 100 for integer precision)

Implementations§

Source§

impl ExecutionUsage

Source

pub fn new(execution_id: ExecutionId, tenant_id: TenantId) -> Self

Create a new usage tracker for an execution

Source

pub fn record_step(&self)

Record step execution

Source

pub fn record_discovered_step(&self)

Record a discovered step (dynamically added to DAG)

Source

pub fn record_tokens(&self, input: u32, output: u32)

Record token usage

Source

pub fn record_cost_usd(&self, cost_usd: f64)

Record cost in USD (converted to cents for storage)

Source

pub fn push_discovery_depth(&self)

Push discovery depth (entering a discovered step)

Source

pub fn pop_discovery_depth(&self)

Pop discovery depth (exiting a discovered step)

Source

pub async fn touch(&self)

Update last activity timestamp

Source

pub fn step_count(&self) -> u32

Get current step count

Source

pub fn discovered_step_count(&self) -> u32

Get discovered step count

Source

pub fn current_discovery_depth(&self) -> u32

Get current discovery depth

Source

pub fn total_tokens(&self) -> u32

Get total token count

Source

pub fn cost_usd(&self) -> f64

Get cumulative cost in USD

Source

pub fn wall_time(&self) -> Duration

Get wall clock duration

Source

pub fn wall_time_ms(&self) -> u64

Get wall time in milliseconds

Source

pub async fn idle_duration(&self) -> Duration

Get idle duration (time since last activity)

Source

pub async fn idle_seconds(&self) -> u64

Get idle duration in seconds

Trait Implementations§

Source§

impl Debug for ExecutionUsage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&ExecutionUsage> for UsageSnapshot

Source§

fn from(usage: &ExecutionUsage) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more