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: AtomicU64Current count of accepted control connections.
control_connections_accepted_total: AtomicU64Cumulative count of accepted control connections.
control_connections_rejected_total: AtomicU64Cumulative count of rejected control connections (auth failures).
control_reconnects_total: AtomicU64Cumulative client reconnect attempts.
auth_failures_total: AtomicU64Cumulative auth failures (may overlap with rejected control connections when the auth phase is the rejection cause).
heartbeat_failures_total: AtomicU64Cumulative heartbeat / keepalive failures detected.
drain_total: AtomicU64Cumulative drain operations completed.
drain_duration_ms_total: AtomicU64Cumulative drain duration in milliseconds.
streams_opened_total: AtomicU64Control sessions initiated.
streams_closed_total: AtomicU64Control sessions completed cleanly.
stream_bytes_total: AtomicU64Total bytes relayed through control channels.
last_error: Mutex<Option<String>>Most recent error message (truncated to 256 chars).
Implementations§
Source§impl ReverseMetrics
impl ReverseMetrics
pub fn new() -> Self
Sourcepub fn record_control_accepted(&self, _peer: SocketAddr)
pub fn record_control_accepted(&self, _peer: SocketAddr)
Record a control connection that passed authentication.
Sourcepub fn record_control_closed(&self)
pub fn record_control_closed(&self)
Record that an accepted control connection has closed.
Sourcepub fn record_control_rejected(&self, _peer: SocketAddr, reason: &str)
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).
Sourcepub fn record_auth_failure(&self, _peer: SocketAddr, reason: &str)
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.
Sourcepub fn record_heartbeat_failure(&self)
pub fn record_heartbeat_failure(&self)
Record a heartbeat / keepalive failure.
Sourcepub fn record_drain(&self, duration_ms: u64)
pub fn record_drain(&self, duration_ms: u64)
Record a completed drain operation.
Sourcepub fn record_reconnect(&self)
pub fn record_reconnect(&self)
Record a client reconnect attempt.
Sourcepub fn record_stream_opened(&self)
pub fn record_stream_opened(&self)
Record that a control session was opened (data flowing).
Sourcepub fn record_stream_closed(&self, bytes: u64)
pub fn record_stream_closed(&self, bytes: u64)
Record that a control session completed cleanly.
Sourcepub fn record_state_duration(&self, state: ControlState, duration_ms: u64)
pub fn record_state_duration(&self, state: ControlState, duration_ms: u64)
Record that the connection was in the given state for duration_ms ms.
Sourcepub fn record_error(&self, msg: &str)
pub fn record_error(&self, msg: &str)
Record an error message (truncated to 256 chars).
Sourcepub fn snapshot(&self) -> ReverseMetricsSnapshot
pub fn snapshot(&self) -> ReverseMetricsSnapshot
Take a point-in-time snapshot of all metric values.
Sourcepub fn render_prometheus(&self) -> String
pub fn render_prometheus(&self) -> String
Render counters in Prometheus text exposition format.