Skip to content

Commit

Permalink
errmetrics: refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Kornilios Kourtis <[email protected]>
  • Loading branch information
kkourt committed Dec 12, 2024
1 parent 7dbd046 commit ffc4f82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/errmetrics/errmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Entry struct {
//go:embed fileids.json
var fileIDsJSON []byte

var getFileIDs = sync.OnceValues(func() (map[int]string, error) {
var GetFileIDs = sync.OnceValues(func() (map[int]string, error) {
var entries []Entry
if err := json.Unmarshal(fileIDsJSON, &entries); err != nil {
return nil, err
Expand Down
6 changes: 4 additions & 2 deletions pkg/errmetrics/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"golang.org/x/sys/unix"
)

const UnknownFname = "<unknown>"

type Map struct {
*ebpf.Map
}
Expand Down Expand Up @@ -49,15 +51,15 @@ func (m Map) Dump() ([]DumpEntry, error) {
var val []MapVal
var ret []DumpEntry

fileIDs, err := getFileIDs()
fileIDs, err := GetFileIDs()
if err != nil {
return nil, err
}
iter := m.Iterate()
for iter.Next(&key, &val) {
fname, ok := fileIDs[int(key.FileID)]
if !ok {
fname = "<unknown>"
fname = UnknownFname
}
count := 0
for _, v := range val {
Expand Down

0 comments on commit ffc4f82

Please sign in to comment.