2026-08-15 08:17:48 +00:00
|
|
|
//! Distribution-owned telemetry records.
|
2026-06-23 15:42:28 +00:00
|
|
|
|
2026-08-15 08:17:48 +00:00
|
|
|
use telemetry::Record;
|
2026-06-23 15:42:28 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
|
|
/// 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";
|
2026-07-25 20:05:44 +00:00
|
|
|
/// Probe lifecycle events emitted by the SWIM observer.
|
|
|
|
|
pub const SWIM_PROBES: &str = "swim.probes";
|
2026-06-23 15:42:28 +00:00
|
|
|
|
|
|
|
|
/// 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,
|
2026-07-25 20:05:44 +00:00
|
|
|
#[serde(default)]
|
|
|
|
|
pub last_ack_age_ms: Option<u64>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub consecutive_timeouts: u32,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub recent_probe_targets: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub member_state: Option<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 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<u32>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub budget_ms: Option<u64>,
|
|
|
|
|
/// Retained for compatibility with the existing diagnostic field name. The
|
|
|
|
|
/// value is milliseconds in the wall-clock implementation.
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub budget_ticks: Option<u64>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub last_ack_age_ms: Option<u64>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub consecutive_timeouts: u32,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub recent_probe_targets: Vec<String>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub member_state: Option<String>,
|
|
|
|
|
#[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,
|
2026-06-23 15:42:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 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<CacheEntryRec>,
|
|
|
|
|
#[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<RegistryEntryRec>,
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub recent_probe_targets: Vec<String>,
|
|
|
|
|
/// "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;
|
|
|
|
|
}
|
2026-07-25 20:05:44 +00:00
|
|
|
impl Record for SwimProbeEvent {
|
|
|
|
|
const CHANNEL: &'static str = SWIM_PROBES;
|
|
|
|
|
}
|
2026-06-23 15:42:28 +00:00
|
|
|
impl Record for DistributionState {
|
|
|
|
|
const CHANNEL: &'static str = DIST_STATE;
|
|
|
|
|
}
|