diff options
Diffstat (limited to 'adapter')
-rw-r--r-- | adapter/stats_api.go | 14 | ||||
-rw-r--r-- | adapter/statsclient/statseg_v1.go | 8 | ||||
-rw-r--r-- | adapter/statsclient/statseg_v2.go | 8 | ||||
-rw-r--r-- | adapter/vppapiclient/stat_client.go | 2 |
4 files changed, 20 insertions, 12 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)))) |