1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! Stats types for Oxanus job queue monitoring.
use serde::{Deserialize, Serialize};
use crate::job_envelope::JobEnvelope;
/// Overall statistics for the Oxanus job queue system.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Stats {
/// Global aggregate statistics.
pub global: StatsGlobal,
/// List of active processes.
pub processes: Vec<Process>,
/// Jobs currently being processed.
pub processing: Vec<StatsProcessing>,
/// Per-queue statistics.
pub queues: Vec<QueueStats>,
}
/// Global aggregate statistics.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatsGlobal {
/// Total number of jobs (enqueued + scheduled).
pub jobs: usize,
/// Number of jobs currently enqueued.
pub enqueued: usize,
/// Total number of jobs processed.
pub processed: i64,
/// Total number of jobs failed.
pub failed: i64,
/// Number of dead jobs.
pub dead: usize,
/// Number of scheduled jobs.
pub scheduled: usize,
/// Number of jobs in retry queue.
pub retries: usize,
/// Maximum latency across all queues in seconds.
pub latency_s_max: f64,
}
/// Information about a job currently being processed.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatsProcessing {
/// The process ID handling the job.
pub process_id: String,
/// The job envelope being processed.
pub job_envelope: JobEnvelope,
}
/// Statistics for a specific queue.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueueStats {
/// The queue key/name.
pub key: String,
/// Number of jobs currently enqueued.
pub enqueued: usize,
/// Total number of jobs processed.
pub processed: i64,
/// Total number of jobs succeeded.
pub succeeded: i64,
/// Total number of jobs panicked.
pub panicked: i64,
/// Total number of jobs failed.
pub failed: i64,
/// Current latency in seconds.
pub latency_s: f64,
/// Dynamic sub-queue statistics (if any).
#[serde(skip_serializing_if = "Vec::is_empty")]
pub queues: Vec<DynamicQueueStats>,
}
/// Statistics for a dynamic sub-queue.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DynamicQueueStats {
/// The dynamic queue suffix.
pub suffix: String,
/// Number of jobs currently enqueued.
pub enqueued: usize,
/// Total number of jobs processed.
pub processed: i64,
/// Total number of jobs succeeded.
pub succeeded: i64,
/// Total number of jobs panicked.
pub panicked: i64,
/// Total number of jobs failed.
pub failed: i64,
/// Current latency in seconds.
pub latency_s: f64,
}
/// Information about an Oxanus worker process.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Process {
/// The hostname where the process is running.
pub hostname: String,
/// The process ID.
pub pid: u32,
/// Last heartbeat timestamp (Unix timestamp).
pub heartbeat_at: i64,
/// Process start timestamp (Unix timestamp).
pub started_at: i64,
}
impl Process {
/// Returns a unique identifier for the process.
#[must_use]
pub fn id(&self) -> String {
format!("{}-{}", self.hostname, self.pid)
}
}