Skip to main content

sedsnet/
diagnostics.rs

1use alloc::vec::Vec;
2
3use crate::{DataType, RouteSelectionMode};
4
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct RuntimeTypeStats {
7    pub data_type: DataType,
8    pub tx_packets: u64,
9    pub tx_bytes: u64,
10    pub rx_packets: u64,
11    pub rx_bytes: u64,
12    pub relayed_tx_packets: u64,
13    pub relayed_tx_bytes: u64,
14    pub relayed_rx_packets: u64,
15    pub relayed_rx_bytes: u64,
16    pub tx_retries: u64,
17    pub handler_failures: u64,
18}
19
20#[derive(Debug, Clone, PartialEq, Eq)]
21pub struct AdaptiveLinkStats {
22    pub auto_balancing_enabled: bool,
23    pub estimated_capacity_bps: u64,
24    pub peak_capacity_bps: u64,
25    pub current_usage_bps: u64,
26    pub peak_usage_bps: u64,
27    pub available_headroom_bps: u64,
28    pub effective_weight: u64,
29    pub last_observed_ms: u64,
30    pub sample_count: u64,
31}
32
33#[derive(Debug, Clone, PartialEq, Eq)]
34pub struct RuntimeSideStats {
35    pub side_id: usize,
36    pub side_name: &'static str,
37    pub reliable_enabled: bool,
38    pub link_local_enabled: bool,
39    pub header_template_enabled: bool,
40    pub max_frame_bytes: usize,
41    pub compact_header_target_bytes: usize,
42    pub side_transport_profile: &'static str,
43    pub ingress_enabled: bool,
44    pub egress_enabled: bool,
45    pub tx_packets: u64,
46    pub tx_bytes: u64,
47    pub rx_packets: u64,
48    pub rx_bytes: u64,
49    pub relayed_tx_packets: u64,
50    pub relayed_tx_bytes: u64,
51    pub relayed_rx_packets: u64,
52    pub relayed_rx_bytes: u64,
53    pub local_delivery_packets: u64,
54    pub tx_retries: u64,
55    pub tx_handler_failures: u64,
56    pub local_handler_failures: u64,
57    pub total_handler_retries: u64,
58    pub side_transport_full_frames: u64,
59    pub side_transport_compact_frames: u64,
60    pub side_transport_compact_delta_frames: u64,
61    pub side_transport_compact_omitted_timestamp_frames: u64,
62    pub side_transport_chunk_frames: u64,
63    pub side_transport_raw_bytes: u64,
64    pub side_transport_wire_bytes: u64,
65    pub side_transport_bytes_saved: u64,
66    pub side_transport_min_compact_overhead_bytes: Option<usize>,
67    pub side_transport_max_compact_overhead_bytes: Option<usize>,
68    pub side_transport_compact_target_misses: u64,
69    pub side_transport_template_evictions: u64,
70    pub side_transport_tx_template_count: usize,
71    pub side_transport_rx_template_count: usize,
72    pub max_side_transport_templates: usize,
73    pub adaptive: AdaptiveLinkStats,
74    pub data_types: Vec<RuntimeTypeStats>,
75}
76
77#[derive(Debug, Clone, PartialEq, Eq)]
78pub struct RouteModeStats {
79    pub src_side_id: Option<usize>,
80    pub selection_mode: Option<RouteSelectionMode>,
81    pub cursor: u64,
82}
83
84#[derive(Debug, Clone, PartialEq, Eq)]
85pub struct RouteOverrideStats {
86    pub src_side_id: Option<usize>,
87    pub dst_side_id: usize,
88    pub enabled: bool,
89}
90
91#[derive(Debug, Clone, PartialEq, Eq)]
92pub struct TypedRouteOverrideStats {
93    pub src_side_id: Option<usize>,
94    pub data_type: DataType,
95    pub dst_side_id: usize,
96    pub enabled: bool,
97}
98
99#[derive(Debug, Clone, PartialEq, Eq)]
100pub struct RouteWeightStats {
101    pub src_side_id: Option<usize>,
102    pub dst_side_id: usize,
103    pub weight: u32,
104}
105
106#[derive(Debug, Clone, PartialEq, Eq)]
107pub struct RoutePriorityStats {
108    pub src_side_id: Option<usize>,
109    pub dst_side_id: usize,
110    pub priority: u32,
111}
112
113#[derive(Debug, Clone, PartialEq, Eq)]
114pub struct QueueRuntimeStats {
115    pub rx_len: usize,
116    pub rx_bytes: usize,
117    pub tx_len: usize,
118    pub tx_bytes: usize,
119    pub replay_len: usize,
120    pub replay_bytes: usize,
121    pub recent_rx_len: usize,
122    pub recent_rx_bytes: usize,
123    pub reliable_rx_buffered_len: usize,
124    pub reliable_rx_buffered_bytes: usize,
125    pub shared_queue_bytes_used: usize,
126}
127
128#[derive(Debug, Clone, PartialEq, Eq)]
129pub struct ReliableRuntimeStats {
130    pub reliable_return_route_count: usize,
131    pub end_to_end_pending_count: usize,
132    pub end_to_end_pending_destination_count: usize,
133    pub end_to_end_acked_cache_count: usize,
134}
135
136#[derive(Debug, Clone, PartialEq, Eq)]
137pub struct DiscoveryRuntimeStats {
138    pub route_count: usize,
139    pub announcer_count: usize,
140    pub current_announce_interval_ms: Option<u64>,
141    pub next_announce_ms: Option<u64>,
142}
143
144#[derive(Debug, Clone, PartialEq, Eq)]
145pub struct RuntimeStatsSnapshot {
146    pub sides: Vec<RuntimeSideStats>,
147    pub route_modes: Vec<RouteModeStats>,
148    pub route_overrides: Vec<RouteOverrideStats>,
149    pub typed_route_overrides: Vec<TypedRouteOverrideStats>,
150    pub route_weights: Vec<RouteWeightStats>,
151    pub route_priorities: Vec<RoutePriorityStats>,
152    pub queues: QueueRuntimeStats,
153    pub reliable: ReliableRuntimeStats,
154    pub discovery: DiscoveryRuntimeStats,
155    pub total_handler_failures: u64,
156    pub total_handler_retries: u64,
157}