pub trait MetricsObserver:
Send
+ Sync
+ 'static {
// Required method
fn command_completed(
&self,
command: &str,
in_bytes: usize,
out_bytes: usize,
duration: Duration,
is_error: bool,
);
// Provided methods
fn connection_opened(&self) { ... }
fn connection_closed(&self) { ... }
fn connection_refused(&self) { ... }
fn push_emitted(&self, out_bytes: usize) { ... }
}Expand description
Receives one callback per completed command, plus connection lifecycle.
Every method must be cheap and must not block: they run on the connection’s writer task, so time spent here is time the socket is not being written. Anything expensive belongs behind a channel.
Required Methods§
Sourcefn command_completed(
&self,
command: &str,
in_bytes: usize,
out_bytes: usize,
duration: Duration,
is_error: bool,
)
fn command_completed( &self, command: &str, in_bytes: usize, out_bytes: usize, duration: Duration, is_error: bool, )
One command completed and its response left the socket.
in_bytes is the request frame size from the decoder and out_bytes
the encoded response length — neither is ever re-encoded to be measured
(SRV-007). duration is the dispatch time, and is_error reflects the
response carrying Err, not a transport failure.
Provided Methods§
Sourcefn connection_opened(&self)
fn connection_opened(&self)
A connection was accepted.
Sourcefn connection_closed(&self)
fn connection_closed(&self)
A connection finished draining and closed.
Sourcefn connection_refused(&self)
fn connection_refused(&self)
An accept was refused at the max_connections ceiling.
Sourcefn push_emitted(&self, out_bytes: usize)
fn push_emitted(&self, out_bytes: usize)
A server-initiated frame was written (id == PUSH_ID, WIRE-005).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".