Trait HistoryListener

Source
pub trait HistoryListener:
    Debug
    + Send
    + Sync {
    // Required methods
    fn log_request_start(&self) -> RequestId;
    fn log_request_success(&self, request_id: RequestId);
    fn log_request_error(&self, request_id: RequestId, error: &RequestError);
    fn log_new_speculative_fiber(&self, request_id: RequestId) -> SpeculativeId;
    fn log_attempt_start(
        &self,
        request_id: RequestId,
        speculative_id: Option<SpeculativeId>,
        node_addr: SocketAddr,
    ) -> AttemptId;
    fn log_attempt_success(&self, attempt_id: AttemptId);
    fn log_attempt_error(
        &self,
        attempt_id: AttemptId,
        error: &RequestAttemptError,
        retry_decision: &RetryDecision,
    );
}
Expand description

Any type implementing this trait can be passed to Session to collect execution history of specific requests.
In order to use it call set_history_listener on Query, PreparedStatement, etc…
The listener has to generate unique IDs for new requests, attempts and speculative fibers. These ids are then used by the caller to identify them.
It’s important to note that even after a request is finished there still might come events related to it. These events come from speculative futures that didn’t notice the request is done already.

Required Methods§

Source

fn log_request_start(&self) -> RequestId

Log that a request has started on request start - right after the call to Session::{query,execute}_*/batch.

Source

fn log_request_success(&self, request_id: RequestId)

Log that request was successful - called right before returning the result from Session::query_, execute_, etc.

Source

fn log_request_error(&self, request_id: RequestId, error: &RequestError)

Log that request ended with an error - called right before returning the error from Session::query_, execute_, etc.

Source

fn log_new_speculative_fiber(&self, request_id: RequestId) -> SpeculativeId

Log that a new speculative fiber has started.

Source

fn log_attempt_start( &self, request_id: RequestId, speculative_id: Option<SpeculativeId>, node_addr: SocketAddr, ) -> AttemptId

Log that an attempt has started - request has been sent on some Connection, now awaiting for an answer.

Source

fn log_attempt_success(&self, attempt_id: AttemptId)

Log that an attempt succeeded.

Source

fn log_attempt_error( &self, attempt_id: AttemptId, error: &RequestAttemptError, retry_decision: &RetryDecision, )

Log that an attempt ended with an error. The error and decision whether to retry the attempt are also included in the log.

Implementors§