summaryrefslogtreecommitdiffstats
path: root/adapter/statsclient/stat_segment_api.go
diff options
context:
space:
mode:
authorVladimir Lavor <vlavor@cisco.com>2022-05-05 10:56:23 +0200
committerVladimir Lavor <vlavor@cisco.com>2022-05-05 11:28:52 +0200
commit874266e00029174d6ad512eeac678b0c99512cd7 (patch)
tree2dba41113b0be28e304051e840863522506e9f57 /adapter/statsclient/stat_segment_api.go
parent945b7c7ae69c414ef851f85596be4edeb1d9290e (diff)
support error counters also as normal counters
https://gerrit.fd.io/r/c/vpp/+/35640 Signed-off-by: Vladimir Lavor <vlavor@cisco.com> Change-Id: I91820bb15655e7b309af814c659eb9f5e7cd08a4
Diffstat (limited to 'adapter/statsclient/stat_segment_api.go')
-rw-r--r--adapter/statsclient/stat_segment_api.go45
1 files changed, 31 insertions, 14 deletions
diff --git a/adapter/statsclient/stat_segment_api.go b/adapter/statsclient/stat_segment_api.go
index 2161e6e..fd7ef36 100644
--- a/adapter/statsclient/stat_segment_api.go
+++ b/adapter/statsclient/stat_segment_api.go
@@ -38,16 +38,24 @@ const (
maxVersion = 2
)
-const (
- statDirIllegal = 0
- statDirScalarIndex = 1
- statDirCounterVectorSimple = 2
- statDirCounterVectorCombined = 3
- statDirErrorIndex = 4
- statDirNameVector = 5
- statDirEmpty = 6
- statDirSymlink = 7
-)
+var dirTypeMapping = map[dirType]adapter.StatType{
+ 1: adapter.ScalarIndex,
+ 2: adapter.SimpleCounterVector,
+ 3: adapter.CombinedCounterVector,
+ 4: adapter.NameVector,
+ 5: adapter.Empty,
+ 6: adapter.Symlink,
+}
+
+var dirTypeMappingLegacy = map[dirType]adapter.StatType{
+ 1: adapter.ScalarIndex,
+ 2: adapter.SimpleCounterVector,
+ 3: adapter.CombinedCounterVector,
+ 4: adapter.ErrorIndex,
+ 5: adapter.NameVector,
+ 6: adapter.Empty,
+ 7: adapter.Symlink,
+}
type (
dirVector unsafe.Pointer
@@ -92,10 +100,6 @@ type vecHeader struct {
vectorData [0]uint8
}
-func (t dirType) String() string {
- return adapter.StatType(t).String()
-}
-
func getVersion(data []byte) uint64 {
type apiVersion struct {
value uint64
@@ -113,6 +117,19 @@ func vectorLen(v dirVector) dirVector {
return dirVector(&vec.length)
}
+func getStatType(dirTypeNum dirType, useLegacyMapping bool) (dirTyp adapter.StatType) {
+ var exists bool
+ if useLegacyMapping {
+ dirTyp, exists = dirTypeMappingLegacy[dirTypeNum]
+ } else {
+ dirTyp, exists = dirTypeMapping[dirTypeNum]
+ }
+ if exists {
+ return dirTyp
+ }
+ return adapter.Unknown
+}
+
//go:nosplit
func statSegPointer(v dirVector, offset uintptr) dirVector {
return dirVector(uintptr(v) + offset)