summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Lavor <vlavor@cisco.com>2021-03-02 11:45:37 +0100
committerOndrej Fabry <ofabry@cisco.com>2021-03-03 12:37:18 +0000
commit4e16c7100cc7f8dddca051ff393460d7a1a77c98 (patch)
treedd8ab474f96025a0ec7f7f6fc7507a5663d9b6c6
parent4459b648e9fb53c34abbf52a00e63ad384fb9ee2 (diff)
Provide error counters per worker for statsclient
Instead of a single value, the ErrorCounter now contains an array representing couter values per workers. Change-Id: I2b869e5b228bcb3e155b1fef08a4cd00e7d2e16a Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
-rw-r--r--adapter/stats_api.go14
-rw-r--r--adapter/statsclient/statseg_v1.go8
-rw-r--r--adapter/statsclient/statseg_v2.go8
-rw-r--r--adapter/vppapiclient/stat_client.go2
-rw-r--r--api/stats.go2
-rw-r--r--core/stats.go6
-rw-r--r--examples/stats-client/stats_api.go9
7 files changed, 33 insertions, 16 deletions
diff --git a/adapter/stats_api.go b/adapter/stats_api.go
index 15c3789..4b398f5 100644
--- a/adapter/stats_api.go
+++ b/adapter/stats_api.go
@@ -126,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.
@@ -154,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 {
diff --git a/adapter/statsclient/statseg_v1.go b/adapter/statsclient/statseg_v1.go
index 3d45201..38f51bd 100644
--- a/adapter/statsclient/statseg_v1.go
+++ b/adapter/statsclient/statseg_v1.go
@@ -113,7 +113,7 @@ func (ss *statSegmentV1) CopyEntryData(statSegDir unsafe.Pointer) adapter.Stat {
_, errOffset, _ := ss.getOffsets()
offsetVector := unsafe.Pointer(&ss.sharedHeader[errOffset])
- var errData adapter.Counter
+ var errData []adapter.Counter
vecLen := *(*uint32)(vectorLen(offsetVector))
for i := uint32(0); i < vecLen; i++ {
@@ -121,7 +121,7 @@ func (ss *statSegmentV1) CopyEntryData(statSegDir unsafe.Pointer) adapter.Stat {
offset := uintptr(cb) + uintptr(dirEntry.unionData)*unsafe.Sizeof(adapter.Counter(0))
debugf("error index, cb: %d, offset: %d", cb, offset)
val := *(*adapter.Counter)(statSegPointer(unsafe.Pointer(&ss.sharedHeader[0]), offset))
- errData += val
+ errData = append(errData, val)
}
return adapter.ErrorStat(errData)
@@ -239,14 +239,14 @@ func (ss *statSegmentV1) UpdateEntryData(statSegDir unsafe.Pointer, stat *adapte
_, errOffset, _ := ss.getOffsets()
offsetVector := unsafe.Pointer(&ss.sharedHeader[errOffset])
- var errData adapter.Counter
+ var errData []adapter.Counter
vecLen := *(*uint32)(vectorLen(unsafe.Pointer(&ss.sharedHeader[errOffset])))
for i := uint32(0); i < vecLen; i++ {
cb := *(*uint64)(statSegPointer(offsetVector, uintptr(i)*unsafe.Sizeof(uint64(0))))
offset := uintptr(cb) + uintptr(dirEntry.unionData)*unsafe.Sizeof(adapter.Counter(0))
val := *(*adapter.Counter)(statSegPointer(unsafe.Pointer(&ss.sharedHeader[0]), offset))
- errData += val
+ errData = append(errData, val)
}
*stat = adapter.ErrorStat(errData)
diff --git a/adapter/statsclient/statseg_v2.go b/adapter/statsclient/statseg_v2.go
index d52077f..68411f9 100644
--- a/adapter/statsclient/statseg_v2.go
+++ b/adapter/statsclient/statseg_v2.go
@@ -105,7 +105,7 @@ func (ss *statSegmentV2) CopyEntryData(statSegDir unsafe.Pointer) adapter.Stat {
return nil
}
vecLen := *(*uint32)(vectorLen(dirVector))
- var errData adapter.Counter
+ var errData []adapter.Counter
for i := uint32(0); i < vecLen; i++ {
cb := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0)))
cbVal := ss.adjust(vectorLen(cb))
@@ -115,7 +115,7 @@ func (ss *statSegmentV2) CopyEntryData(statSegDir unsafe.Pointer) adapter.Stat {
}
offset := uintptr(dirEntry.unionData) * unsafe.Sizeof(adapter.Counter(0))
val := *(*adapter.Counter)(statSegPointer(cbVal, offset))
- errData += val
+ errData = append(errData, val)
}
return adapter.ErrorStat(errData)
@@ -224,7 +224,7 @@ func (ss *statSegmentV2) UpdateEntryData(statSegDir unsafe.Pointer, stat *adapte
return nil
}
vecLen := *(*uint32)(vectorLen(dirVector))
- var errData adapter.Counter
+ var errData []adapter.Counter
for i := uint32(0); i < vecLen; i++ {
cb := statSegPointer(dirVector, uintptr(i+1)*unsafe.Sizeof(uint64(0)))
cbVal := ss.adjust(vectorLen(cb))
@@ -234,7 +234,7 @@ func (ss *statSegmentV2) UpdateEntryData(statSegDir unsafe.Pointer, stat *adapte
}
offset := uintptr(dirEntry.unionData) * unsafe.Sizeof(adapter.Counter(0))
val := *(*adapter.Counter)(statSegPointer(cbVal, offset))
- errData += val
+ errData = append(errData, val)
}
*stat = adapter.ErrorStat(errData)
diff --git a/adapter/vppapiclient/stat_client.go b/adapter/vppapiclient/stat_client.go
index bf19c45..a124f59 100644
--- a/adapter/vppapiclient/stat_client.go
+++ b/adapter/vppapiclient/stat_client.go
@@ -130,7 +130,7 @@ func (c *statClient) DumpStats(patterns ...string) (stats []adapter.StatEntry, e
stat.Data = adapter.ScalarStat(C.govpp_stat_segment_data_get_scalar_value(&v))
case adapter.ErrorIndex:
- stat.Data = adapter.ErrorStat(C.govpp_stat_segment_data_get_error_value(&v))
+ stat.Data = adapter.ErrorStat([]adapter.Counter{adapter.Counter(C.govpp_stat_segment_data_get_error_value(&v))})
case adapter.SimpleCounterVector:
length := int(C.govpp_stat_segment_vec_len(unsafe.Pointer(C.govpp_stat_segment_data_get_simple_counter(&v))))
diff --git a/api/stats.go b/api/stats.go
index 9e1ba75..3a72c6c 100644
--- a/api/stats.go
+++ b/api/stats.go
@@ -98,7 +98,7 @@ type ErrorStats struct {
type ErrorCounter struct {
CounterName string
- Value uint64
+ Values []uint64
}
// BufferStats represents statistics per buffer pool.
diff --git a/core/stats.go b/core/stats.go
index 55c287e..3218f1e 100644
--- a/core/stats.go
+++ b/core/stats.go
@@ -305,7 +305,11 @@ func (c *StatsConnection) GetErrorStats(errorStats *api.ErrorStats) (err error)
continue
}
if errStat, ok := stat.Data.(adapter.ErrorStat); ok {
- errorStats.Errors[i].Value = uint64(errStat)
+ values := make([]uint64, len(errStat))
+ for j, errStatW := range errStat {
+ values[j] = uint64(errStatW)
+ }
+ errorStats.Errors[i].Values = values
}
}
diff --git a/examples/stats-client/stats_api.go b/examples/stats-client/stats_api.go
index 66dd451..0ccfa89 100644
--- a/examples/stats-client/stats_api.go
+++ b/examples/stats-client/stats_api.go
@@ -137,10 +137,15 @@ func main() {
}
n := 0
for _, counter := range stats.Errors {
- if skipZeros && counter.Value == 0 {
+ var sum uint32
+ for _, valuePerWorker := range counter.Values {
+ sum += uint32(valuePerWorker)
+ }
+
+ if skipZeros && sum == 0 {
continue
}
- fmt.Printf(" - %v\n", counter)
+ fmt.Printf(" - %v %d (per worker: %v)\n", counter.CounterName, sum, counter.Values)
n++
}
fmt.Printf("Listed %d (%d) error counters\n", n, len(stats.Errors))