Provide error counters per worker for statsclient
[govpp.git] / adapter / stats_api.go
index d67434c..4b398f5 100644 (file)
@@ -27,6 +27,7 @@ const (
 var (
        ErrStatsDataBusy     = errors.New("stats data busy")
        ErrStatsDirStale     = errors.New("stats dir stale")
+       ErrStatsDisconnected = errors.New("stats disconnected")
        ErrStatsAccessFailed = errors.New("stats access failed")
 )
 
@@ -113,7 +114,7 @@ func (n Name) String() string {
        return string(n)
 }
 
-// Data represents some type of stat which is usually defined by StatType.
+// Stat represents some type of stat which is usually defined by StatType.
 type Stat interface {
        // IsZero returns true if all of its values equal to zero.
        IsZero() bool
@@ -125,8 +126,8 @@ type Stat interface {
 // ScalarStat represents stat for ScalarIndex.
 type ScalarStat float64
 
-// ErrorStat represents stat for ErrorIndex.
-type ErrorStat Counter
+// ErrorStat represents stat for ErrorIndex. The array represents workers.
+type ErrorStat []Counter
 
 // SimpleCounterStat represents stat for SimpleCounterVector.
 // The outer array represents workers and the inner array represents interface/node/.. indexes.
@@ -153,7 +154,15 @@ func (s ScalarStat) IsZero() bool {
        return s == 0
 }
 func (s ErrorStat) IsZero() bool {
-       return s == 0
+       if s == nil {
+               return true
+       }
+       for _, ss := range s {
+               if ss != 0 {
+                       return false
+               }
+       }
+       return true
 }
 func (s SimpleCounterStat) IsZero() bool {
        if s == nil {
@@ -205,7 +214,7 @@ func ReduceSimpleCounterStatIndex(s SimpleCounterStat, i int) uint64 {
        return val
 }
 
-// ReduceSimpleCounterStatIndex returns reduced CombinedCounterStat s for index i.
+// ReduceCombinedCounterStatIndex returns reduced CombinedCounterStat s for index i.
 func ReduceCombinedCounterStatIndex(s CombinedCounterStat, i int) [2]uint64 {
        var val [2]uint64
        for _, w := range s {