-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfailover.rs
More file actions
36 lines (31 loc) · 1.06 KB
/
failover.rs
File metadata and controls
36 lines (31 loc) · 1.06 KB
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
use metrics::{Unit, describe_gauge, gauge};
/// Metric name for tracking if a stream is currently in failover mode.
///
/// This gauge is set to 1 when the stream is in failover mode and 0 otherwise.
const STREAM_FAILOVER_ACTIVE: &str = "stream_failover_active";
/// Label key for stream identifier.
const STREAM_ID_LABEL: &str = "stream_id";
/// Registers failover metric descriptions with the global metrics recorder.
pub(crate) fn register_failover_metrics() {
describe_gauge!(
STREAM_FAILOVER_ACTIVE,
Unit::Count,
"Whether the stream is currently in failover mode (1 = failover, 0 = healthy)"
);
}
/// Records that the stream has entered failover mode.
pub fn record_failover_entered(stream_id: u64) {
gauge!(
STREAM_FAILOVER_ACTIVE,
STREAM_ID_LABEL => stream_id.to_string()
)
.set(1.0);
}
/// Records that the stream has recovered from failover mode.
pub fn record_failover_recovered(stream_id: u64) {
gauge!(
STREAM_FAILOVER_ACTIVE,
STREAM_ID_LABEL => stream_id.to_string()
)
.set(0.0);
}