diff --git a/pkg/errmetrics/errmetrics.go b/pkg/errmetrics/errmetrics.go index 238a6e3d9b8..ffa33deab1f 100644 --- a/pkg/errmetrics/errmetrics.go +++ b/pkg/errmetrics/errmetrics.go @@ -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 diff --git a/pkg/errmetrics/map.go b/pkg/errmetrics/map.go index c7f755c4913..a96b6683af3 100644 --- a/pkg/errmetrics/map.go +++ b/pkg/errmetrics/map.go @@ -11,6 +11,8 @@ import ( "golang.org/x/sys/unix" ) +const UnknownFname = "" + type Map struct { *ebpf.Map } @@ -49,7 +51,7 @@ func (m Map) Dump() ([]DumpEntry, error) { var val []MapVal var ret []DumpEntry - fileIDs, err := getFileIDs() + fileIDs, err := GetFileIDs() if err != nil { return nil, err } @@ -57,7 +59,7 @@ func (m Map) Dump() ([]DumpEntry, error) { for iter.Next(&key, &val) { fname, ok := fileIDs[int(key.FileID)] if !ok { - fname = "" + fname = UnknownFname } count := 0 for _, v := range val {