//! Distribution-owned telemetry records. use serde::{Deserialize, Serialize}; use telemetry::Record; /// Transport internals — connectivity to peers and relay. pub const TRANSPORT_INTERNALS: &str = "transport.internals"; /// Membership / liveness transitions. pub const MEMBERSHIP: &str = "membership"; /// Distribution-subsystem state: cache, directory, registry, probes, peer auth. pub const DIST_STATE: &str = "dist.state"; /// Probe lifecycle events emitted by the SWIM observer. pub const SWIM_PROBES: &str = "swim.probes"; /// Transport-internals record. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct TransportInternals { #[serde(default)] pub relay_connected: bool, #[serde(default)] pub direct_peers: u32, #[serde(default)] pub relay_peers: u32, #[serde(default)] pub rtt_ms_p50: u32, } /// Membership / liveness transition. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct MembershipTransition { pub peer: String, pub from: String, pub to: String, #[serde(default)] pub reason: String, #[serde(default)] pub last_ack_age_ms: Option, #[serde(default)] pub consecutive_timeouts: u32, #[serde(default)] pub recent_probe_targets: Vec, #[serde(default)] pub member_state: Option, } /// One SWIM probe lifecycle event. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct SwimProbeEvent { /// `"sent"`, `"acked"`, or `"timed_out"`. pub event: String, pub target: String, pub sequence: u64, /// `"direct"` or `"indirect"`. pub kind: String, #[serde(default)] pub rtt_ms: Option, #[serde(default)] pub budget_ms: Option, /// Retained for compatibility with the existing diagnostic field name. The /// value is milliseconds in the wall-clock implementation. #[serde(default)] pub budget_ticks: Option, #[serde(default)] pub last_ack_age_ms: Option, #[serde(default)] pub consecutive_timeouts: u32, #[serde(default)] pub recent_probe_targets: Vec, #[serde(default)] pub member_state: Option, #[serde(default)] pub local_phase: String, #[serde(default)] pub probe_interval_ms: u64, #[serde(default)] pub probe_timeout_ms: u64, #[serde(default)] pub indirect_probes: u32, #[serde(default)] pub suspicion_timeout_ms: u64, #[serde(default)] pub dead_reprobe_interval_ms: u64, #[serde(default)] pub probe_mode: String, #[serde(default)] pub lifeguard_enabled: bool, } /// Consolidated distribution-subsystem state. #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct DistributionState { #[serde(default)] pub cache_size: u32, #[serde(default)] pub cache_entries: Vec, #[serde(default)] pub directory_route_count: u32, #[serde(default)] pub registry_size: u32, #[serde(default)] pub registry_tombstones: u32, #[serde(default)] pub registry_entries: Vec, #[serde(default)] pub recent_probe_targets: Vec, /// "open" or "allow-list". #[serde(default)] pub peer_auth_mode: String, /// Authorized peers in allow-list mode; 0 in open mode. #[serde(default)] pub authorized_peer_count: u32, } /// One location-cache entry: which node an actor address resolves to. #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct CacheEntryRec { #[serde(default)] pub actor_addr: String, #[serde(default)] pub node_id: String, } /// One cluster-registry entry, possibly a tombstone. #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct RegistryEntryRec { #[serde(default)] pub name: String, #[serde(default)] pub actor_addr: String, #[serde(default)] pub node_id: String, #[serde(default)] pub tombstone: bool, } impl Record for TransportInternals { const CHANNEL: &'static str = TRANSPORT_INTERNALS; } impl Record for MembershipTransition { const CHANNEL: &'static str = MEMBERSHIP; } impl Record for SwimProbeEvent { const CHANNEL: &'static str = SWIM_PROBES; } impl Record for DistributionState { const CHANNEL: &'static str = DIST_STATE; }