pub struct MetricsCounters {
pub accepted_connections: AtomicU64,
pub dispatched_requests: AtomicU64,
pub dispatch_errors_by_code: Mutex<BTreeMap<u16, u64>>,
pub audit_events_total: AtomicU64,
pub audit_drops_total: AtomicU64,
}Expand description
Hot-path counters owned by ServerState. All fields are atomic so
every transport (UDS via atd-server, HTTP via atd-server-http) and
every dispatch path can bump them without coordinating.
Fields§
§accepted_connections: AtomicU64Total UDS / HTTP connections accepted since startup.
dispatched_requests: AtomicU64Total Request frames dispatched (Ping, Hello, ToolList, ToolSchema,
RunTool — every variant counts).
dispatch_errors_by_code: Mutex<BTreeMap<u16, u64>>Per-error-code counter, lazily allocated. Keyed by Response::Error.code
(the same u16s atd_protocol::ERR_* constants define). Sparse: most
codes are never hit on a given server.
audit_events_total: AtomicU64Total audit events successfully enqueued onto the audit sink.
audit_drops_total: AtomicU64Total audit events dropped because the audit sink’s queue was full (SP-concurrency-baseline §5.4 mpsc backpressure).
Implementations§
Source§impl MetricsCounters
impl MetricsCounters
Sourcepub fn record_error(&self, code: u16)
pub fn record_error(&self, code: u16)
Bump a dispatch-error code counter. Called from dispatch error branches. Lock contention is acceptable here: errors are by definition tail events; the success hot path doesn’t touch this map.
Sourcepub fn snapshot(&self) -> MetricsSnapshot
pub fn snapshot(&self) -> MetricsSnapshot
Capture a snapshot suitable for serializing into a /metrics body
or a health-check endpoint.