pub struct ActorMetrics {
pub messages_received: AtomicU64,
pub messages_processed: AtomicU64,
pub messages_failed: AtomicU64,
pub heartbeats: AtomicU64,
pub last_message_at: AtomicU64,
pub restart_count: AtomicU64,
pub llm_input_tokens: AtomicU64,
pub llm_output_tokens: AtomicU64,
pub llm_cost_nano_usd: AtomicU64,
}Expand description
Atomic runtime counters for an actor.
All fields use relaxed ordering because cross-thread ordering guarantees are not required for telemetry — occasional skew is acceptable.
Fields§
§messages_received: AtomicU64Total messages received since the actor started.
messages_processed: AtomicU64Total messages successfully processed.
messages_failed: AtomicU64Total messages that raised an error during processing.
heartbeats: AtomicU64Number of heartbeat ticks emitted.
last_message_at: AtomicU64UNIX timestamp (seconds) of the last received message.
restart_count: AtomicU64Number of supervisor-triggered restarts for this actor.
llm_input_tokens: AtomicU64Total LLM input tokens consumed by this actor.
llm_output_tokens: AtomicU64Total LLM output tokens produced by this actor.
llm_cost_nano_usd: AtomicU64Total LLM cost in nano-USD (divide by 1_000_000_000 for USD).
Implementations§
Source§impl ActorMetrics
impl ActorMetrics
pub fn new() -> Self
pub fn record_received(&self)
pub fn record_processed(&self)
pub fn record_failed(&self)
pub fn record_heartbeat(&self)
pub fn record_restart(&self)
Sourcepub fn record_llm_usage(
&self,
input_tokens: u64,
output_tokens: u64,
cost_nano_usd: u64,
)
pub fn record_llm_usage( &self, input_tokens: u64, output_tokens: u64, cost_nano_usd: u64, )
Record LLM usage: token counts and cost (in nano-USD).
Sourcepub fn snapshot(&self) -> MetricsSnapshot
pub fn snapshot(&self) -> MetricsSnapshot
Snapshot current counters as a serializable struct.
Trait Implementations§
Source§impl Debug for ActorMetrics
impl Debug for ActorMetrics
Source§impl Default for ActorMetrics
impl Default for ActorMetrics
Source§fn default() -> ActorMetrics
fn default() -> ActorMetrics
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ActorMetrics
impl RefUnwindSafe for ActorMetrics
impl Send for ActorMetrics
impl Sync for ActorMetrics
impl Unpin for ActorMetrics
impl UnwindSafe for ActorMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more