Skip to main content

ReverseMetrics

Struct ReverseMetrics 

Source
pub struct ReverseMetrics {
    pub control_connections_active: AtomicU64,
    pub control_connections_accepted_total: AtomicU64,
    pub control_connections_rejected_total: AtomicU64,
    pub control_reconnects_total: AtomicU64,
    pub auth_failures_total: AtomicU64,
    pub heartbeat_failures_total: AtomicU64,
    pub drain_total: AtomicU64,
    pub drain_duration_ms_total: AtomicU64,
    pub streams_opened_total: AtomicU64,
    pub streams_closed_total: AtomicU64,
    pub stream_bytes_total: AtomicU64,
    pub last_error: Mutex<Option<String>>,
    /* private fields */
}
Expand description

Reverse proxy protocol metrics.

Thread-safe counters for control connection lifecycle, stream events, and error tracking. Pass Arc<ReverseMetrics> to ReverseServer or ReverseClient via the set_metrics builder.

Fields§

§control_connections_active: AtomicU64

Current count of accepted control connections.

§control_connections_accepted_total: AtomicU64

Cumulative count of accepted control connections.

§control_connections_rejected_total: AtomicU64

Cumulative count of rejected control connections (auth failures).

§control_reconnects_total: AtomicU64

Cumulative client reconnect attempts.

§auth_failures_total: AtomicU64

Cumulative auth failures (may overlap with rejected control connections when the auth phase is the rejection cause).

§heartbeat_failures_total: AtomicU64

Cumulative heartbeat / keepalive failures detected.

§drain_total: AtomicU64

Cumulative drain operations completed.

§drain_duration_ms_total: AtomicU64

Cumulative drain duration in milliseconds.

§streams_opened_total: AtomicU64

Control sessions initiated.

§streams_closed_total: AtomicU64

Control sessions completed cleanly.

§stream_bytes_total: AtomicU64

Total bytes relayed through control channels.

§last_error: Mutex<Option<String>>

Most recent error message (truncated to 256 chars).

Implementations§

Source§

impl ReverseMetrics

Source

pub fn new() -> Self

Source

pub fn record_control_accepted(&self, _peer: SocketAddr)

Record a control connection that passed authentication.

Source

pub fn record_control_closed(&self)

Record that an accepted control connection has closed.

Source

pub fn record_control_rejected(&self, _peer: SocketAddr, reason: &str)

Record a control connection that was rejected (non-auth reason such as max_control_connections).

Source

pub fn record_auth_failure(&self, _peer: SocketAddr, reason: &str)

Record an authentication failure. Also increments the rejected counter since an auth failure is a subset of rejections.

Source

pub fn record_heartbeat_failure(&self)

Record a heartbeat / keepalive failure.

Source

pub fn record_drain(&self, duration_ms: u64)

Record a completed drain operation.

Source

pub fn record_reconnect(&self)

Record a client reconnect attempt.

Source

pub fn record_stream_opened(&self)

Record that a control session was opened (data flowing).

Source

pub fn record_stream_closed(&self, bytes: u64)

Record that a control session completed cleanly.

Source

pub fn record_state_duration(&self, state: ControlState, duration_ms: u64)

Record that the connection was in the given state for duration_ms ms.

Source

pub fn record_error(&self, msg: &str)

Record an error message (truncated to 256 chars).

Source

pub fn snapshot(&self) -> ReverseMetricsSnapshot

Take a point-in-time snapshot of all metric values.

Source

pub fn render_prometheus(&self) -> String

Render counters in Prometheus text exposition format.

Trait Implementations§

Source§

impl Debug for ReverseMetrics

Source§

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

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

impl Default for ReverseMetrics

Source§

fn default() -> Self

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more