github.com/alpe/etcd@v0.1.2-0.20130915230056-09f31af88aeb/store/stats.go (about)

     1  package store
     2  
     3  import (
     4  	"encoding/json"
     5  )
     6  
     7  type EtcdStats struct {
     8  	// Number of get requests
     9  	Gets uint64 `json:"gets"`
    10  
    11  	// Number of sets requests
    12  	Sets uint64 `json:"sets"`
    13  
    14  	// Number of delete requests
    15  	Deletes uint64 `json:"deletes"`
    16  
    17  	// Number of testAndSet requests
    18  	TestAndSets uint64 `json:"testAndSets"`
    19  }
    20  
    21  // Stats returns the basic statistics information of etcd storage since its recent start
    22  func (s *Store) Stats() []byte {
    23  	b, _ := json.Marshal(s.BasicStats)
    24  	return b
    25  }
    26  
    27  // TotalWrites returns the total write operations
    28  // It helps with snapshot
    29  func (s *Store) TotalWrites() uint64 {
    30  	bs := s.BasicStats
    31  
    32  	return bs.Deletes + bs.Sets + bs.TestAndSets
    33  }