stats.go 676 B

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