MCPcopy
hub / github.com/cloudflare/ebpf_exporter / NewSet

Function NewSet

decoder/decoder.go:33–71  ·  view source on GitHub ↗

NewSet creates a Set with all known decoders

(skipCacheSize int, monitor *cgroup.Monitor)

Source from the content-addressed store, hash-verified

31
32// NewSet creates a Set with all known decoders
33func 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
74func (s *Set) decode(in []byte, label config.Label) ([]byte, error) {

Callers 7

NewFunction · 0.92
TestExtractFilledFunction · 0.92
TestDecodeLabelsFunction · 0.85
TestDecodeSkipLabelsFunction · 0.85
TestDecoderSetCacheFunction · 0.85
BenchmarkCacheFunction · 0.85

Calls 1

NewDecoderFunction · 0.92

Tested by 6

TestExtractFilledFunction · 0.74
TestDecodeLabelsFunction · 0.68
TestDecodeSkipLabelsFunction · 0.68
TestDecoderSetCacheFunction · 0.68
BenchmarkCacheFunction · 0.68