Module openraft::metrics

source ·
Expand description

Raft metrics for observability.

Applications may use this data in whatever way is needed. The obvious use cases are to expose these metrics to a metrics collection system like Prometheus. Applications may also use this data to trigger events within higher levels of the parent application.

Metrics are observed on a running Raft node via the Raft::metrics() -> watch::Receiver<RaftMetrics> method, which will return a stream of metrics.

§RaftMetrics

RaftMetrics contains useful information such as:

  • Server state(leader/follower/learner/candidate) of this raft node,
  • The current leader,
  • Last log and applied log.
  • Replication state, if this node is a Leader,
  • Snapshot state,
  • etc.

Metrics can be used as a trigger of application events, as a monitoring data source, etc.

Metrics is not a stream thus it only guarantees to provide the latest state but not every change of the state. Because internally, watch::channel() only stores one last state.

Structs§

  • Subset of RaftMetrics, only include data-related metrics
  • A set of metrics describing the current state of a Raft node.
  • Subset of RaftMetrics, only include server-related metrics
  • Wait is a wrapper of RaftMetrics channel that impls several utils to wait for metrics to satisfy some condition.

Enums§