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
//! Bounded, non-sensitive supervisor and watchdog events.
/// Stable kind emitted for supervisor and watchdog state changes.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SupervisorEventKind {
/// A service started.
ServiceStarted,
/// A service stopped.
ServiceStopped,
/// A restart was accepted into the bounded schedule.
ServiceRestartScheduled,
/// A service restarted.
ServiceRestarted,
/// A service failed.
ServiceFailed,
/// A degraded or failed service recovered.
ServiceRecovered,
/// A service instance outlived its shutdown timeout.
ServiceOrphaned,
/// A service exhausted its restart budget.
RestartBudgetExceeded,
/// A service requires operator intervention.
ServiceQuarantined,
/// A reconciliation cycle completed.
SupervisorProgressed,
/// The watchdog detected absent reconciliation progress.
SupervisorStalled,
/// Reconciliation resumed after a stall.
SupervisorRecovered,
}
/// One bounded, non-sensitive supervisor event.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SupervisorEvent {
/// Service identifier, or `supervisor` for process-level events.
pub service_id: String,
/// Stable event kind.
pub kind: SupervisorEventKind,
/// Event time in Unix milliseconds.
pub timestamp_ms: u64,
/// Restart attempt or reconcile sequence associated with the event.
pub attempt: u64,
/// Controlled reason code without service payloads or secrets.
pub reason: String,
/// Stable previous state label.
pub previous_state: String,
/// Stable new state label.
pub new_state: String,
/// Process-local trace identifier.
pub trace_id: String,
}
impl SupervisorEvent {
pub(crate) fn new(
service_id: impl Into<String>,
kind: SupervisorEventKind,
timestamp_ms: u64,
attempt: u64,
transition: (&str, &str),
reason: &str,
trace_id: String,
) -> Self {
Self {
service_id: service_id.into(),
kind,
timestamp_ms,
attempt,
reason: reason.to_string(),
previous_state: transition.0.to_string(),
new_state: transition.1.to_string(),
trace_id,
}
}
}