feat(obs): add shared diagnostics models
Add the observability vocabulary needed for phase-1 frame logging and client status reporting. Runtime crates can now emit structured events without each binary inventing separate field names for the same tunnel state. The new models cover frame direction, action, drop reason, parsed Ethernet frame logs, malformed frame logs, tunnel counters, relay/QUIC/TAP client diagnostics, and user-facing diagnostic messages. TunnelStats now lives in lanparty-obs and is re-exported by lanparty-ctrl so stats remain one shared type whether they are logged locally or carried over the control stream. This still does not add logging sinks or tracing integration; those should be wired in when the relay, gateway, and client loops exist. Test Plan: - cargo fmt --check - cargo test --workspace - cargo clippy --workspace --all-targets -- -D warnings Refs: PLAN.md Logging / diagnostics
This commit is contained in:
@@ -4,6 +4,7 @@ version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
lanparty-obs = { path = "../lanparty-obs" }
|
||||
lanparty-proto = { path = "../lanparty-proto" }
|
||||
serde.workspace = true
|
||||
thiserror.workspace = true
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
use std::{fmt, str::FromStr};
|
||||
|
||||
pub use lanparty_obs::TunnelStats;
|
||||
use lanparty_proto::{MIN_USEFUL_TAP_MTU, MacAddr, MtuError, recommended_tap_mtu};
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -357,67 +358,6 @@ impl Reject {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Deserialize, serde::Serialize)]
|
||||
pub struct TunnelStats {
|
||||
ethernet_frames_tx: u64,
|
||||
ethernet_frames_rx: u64,
|
||||
datagrams_tx: u64,
|
||||
datagrams_rx: u64,
|
||||
dropped_frames: u64,
|
||||
malformed_frames: u64,
|
||||
}
|
||||
|
||||
impl TunnelStats {
|
||||
#[must_use]
|
||||
pub const fn new(
|
||||
ethernet_frames_tx: u64,
|
||||
ethernet_frames_rx: u64,
|
||||
datagrams_tx: u64,
|
||||
datagrams_rx: u64,
|
||||
dropped_frames: u64,
|
||||
malformed_frames: u64,
|
||||
) -> Self {
|
||||
Self {
|
||||
ethernet_frames_tx,
|
||||
ethernet_frames_rx,
|
||||
datagrams_tx,
|
||||
datagrams_rx,
|
||||
dropped_frames,
|
||||
malformed_frames,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn ethernet_frames_tx(&self) -> u64 {
|
||||
self.ethernet_frames_tx
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn ethernet_frames_rx(&self) -> u64 {
|
||||
self.ethernet_frames_rx
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn datagrams_tx(&self) -> u64 {
|
||||
self.datagrams_tx
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn datagrams_rx(&self) -> u64 {
|
||||
self.datagrams_rx
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn dropped_frames(&self) -> u64 {
|
||||
self.dropped_frames
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn malformed_frames(&self) -> u64 {
|
||||
self.malformed_frames
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
|
||||
#[serde(tag = "type", content = "payload", rename_all = "snake_case")]
|
||||
pub enum ControlMessage {
|
||||
|
||||
Reference in New Issue
Block a user