Skip to main content

MetricsCounters

Struct MetricsCounters 

Source
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: AtomicU64

Total UDS / HTTP connections accepted since startup.

§dispatched_requests: AtomicU64

Total 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: AtomicU64

Total audit events successfully enqueued onto the audit sink.

§audit_drops_total: AtomicU64

Total audit events dropped because the audit sink’s queue was full (SP-concurrency-baseline §5.4 mpsc backpressure).

Implementations§

Source§

impl MetricsCounters

Source

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.

Source

pub fn snapshot(&self) -> MetricsSnapshot

Capture a snapshot suitable for serializing into a /metrics body or a health-check endpoint.

Trait Implementations§

Source§

impl Debug for MetricsCounters

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MetricsCounters

Source§

fn default() -> MetricsCounters

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V