Statistics Methods

The implementation of methods for retrieving etcd cluster statistics also follows the specification given in the etcd API and and etcd Admin API.

getLeaderStats

Gets statistics from the leader of a cluster, which holds information of the whole cluster:

getLeaderStats: Future[EtcdLeaderStatsResult]

Implemented according to etcd Client API: “Leader Statistics”.

getHealth

Checks if a member of a cluster is healthy:

getHealth: Future[EtcdHealthResponse]

Implemented according to etcd Admin API: “Checking health of an etcd member node”.

The following is a simple example of the usage of this method:

etcdcli.getHealth onSuccess {
  case EtcdGetHealthResponse(health) =>
    // should be "true"
    health
}

getSelfStats

Gets statistics stores in the member of an etcd cluster to which the request is addressed:

getSelfStats: Future[EtcdSelfStatsResponse]

Implemented according to etcd Client API: “Self Statistics”.

The following is a simple example of the usage of this method:

etcdcli.getSelfStats onSuccess  {
  case EtcdGetSelfStatsResponse(id: String,
  leaderInfo: EtcdLeaderInfo,
  name: String,
  recvAppendRequestCnt: Int,
  recvBandwidthRate: Option[Double],
  recvPkgRate: Option[Double],
  sendAppendRequestCnt: Int,
  startTime: String,
  state: String) =>
    // sample id string: 77fb14b13d7590f7
    id
}

getStoreStats

Gets statistics of operations that a given etcd member has handeled (store stats):

getStoreStats: Future[EtcdStoreStatsResponse]

Implemented according to etcd Client API: “Store Statistics”.

The following is a simple example of the usage of this method:

etcdcli.getStoreStats onSuccess {
  case EtcdGetStoreStatsResponse(compareAndSwapFail: Int,
  compareAndSwapSuccess: Int,
  createFail: Int,
  createSuccess: Int,
  deleteFail: Int,
  deleteSuccess: Int,
  expireCount: Int,
  getsFail: Int,
  getsSuccess: Int,
  setsFail: Int,
  setsSuccess: Int,
  updateFail: Int,
  updateSuccess: Int,
  watchers: Int) =>
    // shoulb de an integer.
    watchers
}

getVersion

Gets the version of etcd used ina given cluster:

getVersion: Future[EtcdVersionResponse]

Implemented according to etcd Admin API: “Getting the etcd version”.

The following is a simple example of the usage of this method:

etcdcli.getVersion onSuccess {
  case EtcdGetVersionResponse(etcdserver, etcdcluster) =>
    // should be a string starting with "2.3"
    etcdcluster
}