pub struct WorkflowMetrics {
pub workflow_id: WorkflowId,
pub workflow_name: String,
pub state: WorkflowState,
pub start_time: Option<DateTime<Utc>>,
pub end_time: Option<DateTime<Utc>>,
pub duration: Option<Duration>,
pub tasks: HashMap<TaskId, TaskMetrics>,
pub total_tasks: usize,
pub completed_tasks: Arc<AtomicU64>,
pub failed_tasks: Arc<AtomicU64>,
pub running_tasks: Arc<AtomicU64>,
}Expand description
Workflow execution metrics.
The completed_tasks, failed_tasks, and running_tasks counters are
backed by Arc<AtomicU64> so they can be incremented/decremented from
any thread without a mutable borrow. The Arc also allows sharing a
counter across cheap clones (each clone shares the same atomic).
Fields§
§workflow_id: WorkflowIdWorkflow identifier.
workflow_name: StringWorkflow name.
state: WorkflowStateCurrent state.
start_time: Option<DateTime<Utc>>Start time.
end_time: Option<DateTime<Utc>>End time.
duration: Option<Duration>Total duration.
tasks: HashMap<TaskId, TaskMetrics>Task metrics.
total_tasks: usizeTotal task count.
completed_tasks: Arc<AtomicU64>Completed tasks count (atomic for lock-free concurrent updates).
failed_tasks: Arc<AtomicU64>Failed tasks count (atomic for lock-free concurrent updates).
running_tasks: Arc<AtomicU64>Running tasks count (atomic for lock-free concurrent updates).
Implementations§
Source§impl WorkflowMetrics
impl WorkflowMetrics
Sourcepub fn new(
workflow_id: WorkflowId,
workflow_name: String,
total_tasks: usize,
) -> Self
pub fn new( workflow_id: WorkflowId, workflow_name: String, total_tasks: usize, ) -> Self
Create new workflow metrics.
Sourcepub fn completed_tasks_count(&self) -> u64
pub fn completed_tasks_count(&self) -> u64
Read the completed tasks count.
Sourcepub fn failed_tasks_count(&self) -> u64
pub fn failed_tasks_count(&self) -> u64
Read the failed tasks count.
Sourcepub fn running_tasks_count(&self) -> u64
pub fn running_tasks_count(&self) -> u64
Read the running tasks count.
Sourcepub fn mark_started(&mut self)
pub fn mark_started(&mut self)
Mark workflow as started.
Sourcepub fn mark_completed(&mut self)
pub fn mark_completed(&mut self)
Mark workflow as completed.
Sourcepub fn mark_failed(&mut self)
pub fn mark_failed(&mut self)
Mark workflow as failed.
Sourcepub fn update_task(&mut self, task_metrics: TaskMetrics)
pub fn update_task(&mut self, task_metrics: TaskMetrics)
Update task metrics.
Sourcepub fn progress_percentage(&self) -> f64
pub fn progress_percentage(&self) -> f64
Get progress percentage.
Sourcepub fn average_task_duration(&self) -> Option<Duration>
pub fn average_task_duration(&self) -> Option<Duration>
Get average task duration.
Sourcepub fn throughput(&self) -> f64
pub fn throughput(&self) -> f64
Get throughput (tasks per second).
Trait Implementations§
Source§impl Clone for WorkflowMetrics
impl Clone for WorkflowMetrics
Source§fn clone(&self) -> WorkflowMetrics
fn clone(&self) -> WorkflowMetrics
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more