NewSet creates a Set with all known decoders
(skipCacheSize int, monitor *cgroup.Monitor)
| 31 | |
| 32 | // NewSet creates a Set with all known decoders |
| 33 | func NewSet(skipCacheSize int, monitor *cgroup.Monitor) (*Set, error) { |
| 34 | ksym, err := kallsyms.NewDecoder("/proc/kallsyms") |
| 35 | if err != nil { |
| 36 | return nil, fmt.Errorf("error creating ksym decoder: %w", err) |
| 37 | } |
| 38 | |
| 39 | s := &Set{ |
| 40 | decoders: map[string]Decoder{ |
| 41 | "cgroup": &CGroup{monitor}, |
| 42 | "dname": &Dname{}, |
| 43 | "errno": &Errno{}, |
| 44 | "hex": &Hex{}, |
| 45 | "ifname": &IfName{}, |
| 46 | "inet_ip": &InetIP{}, |
| 47 | "kstack": &KStack{ksym}, |
| 48 | "ksym": &KSym{ksym}, |
| 49 | "majorminor": &MajorMinor{}, |
| 50 | "pci_class": &PCIClass{}, |
| 51 | "pci_device": &PCIDevice{}, |
| 52 | "pci_subclass": &PCISubClass{}, |
| 53 | "pci_vendor": &PCIVendor{}, |
| 54 | "regexp": &Regexp{}, |
| 55 | "static_map": &StaticMap{}, |
| 56 | "string": &String{}, |
| 57 | "syscall": &Syscall{}, |
| 58 | "uint": &UInt{}, |
| 59 | }, |
| 60 | cache: map[string]map[string][]string{}, |
| 61 | } |
| 62 | |
| 63 | if skipCacheSize > 0 { |
| 64 | skipCache, err := lru.New[string, struct{}](skipCacheSize) |
| 65 | if err != nil { |
| 66 | return nil, err |
| 67 | } |
| 68 | s.skipCache = skipCache |
| 69 | } |
| 70 | return s, nil |
| 71 | } |
| 72 | |
| 73 | // decode transforms input byte field into a string according to configuration |
| 74 | func (s *Set) decode(in []byte, label config.Label) ([]byte, error) { |