diff options
| author | Paul Buetow <paul@buetow.org> | 2025-03-29 10:27:47 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-03-29 10:27:47 +0200 |
| commit | 5f1b3be8ac4013ac7cf5041de339317defeb75ce (patch) | |
| tree | 3f2df161f6599179c56ca3073cc10ff89a024d1b /internal | |
| parent | 525e38ae59ce7a0d3be49ecba94df678f1def409 (diff) | |
add tpsExclude, rename tracepoints to tps
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/flags/flags.go | 41 | ||||
| -rw-r--r-- | internal/flamegraph/iordata.go | 13 | ||||
| -rw-r--r-- | internal/flamegraph/worker.go | 4 |
3 files changed, 34 insertions, 24 deletions
diff --git a/internal/flags/flags.go b/internal/flags/flags.go index 3686617..7a77ae7 100644 --- a/internal/flags/flags.go +++ b/internal/flags/flags.go @@ -11,15 +11,16 @@ import ( ) type Flags struct { - PidFilter int - TidFilter int - EventMapSize int - CommFilter string - PathFilter string - PprofEnable bool - FlamegraphEnable bool - Duration int - TracepointsToAttach []*regexp.Regexp + PidFilter int + TidFilter int + EventMapSize int + CommFilter string + PathFilter string + PprofEnable bool + FlamegraphEnable bool + Duration int + TracepointsToAttach []*regexp.Regexp + TracepointsToExclude []*regexp.Regexp } func New() (flags Flags) { @@ -34,22 +35,34 @@ func New() (flags Flags) { flag.BoolVar(&flags.PprofEnable, "pprof", false, "Enable profiling") flag.BoolVar(&flags.FlamegraphEnable, "flamegraph", false, "Enable flamegraph builder") - tracepointNames := flag.String("tracepoints", "", "Comma separated list regexes for tracepoints to load") + tracepointsToAttach := flag.String("tps", "", "Comma separated list regexes for tracepoints to load") + tracepointsToExclude := flag.String("tpsExclude", "", "Comma separated list regexes for tracepoints to exclude") flag.Parse() - for _, name := range strings.Split(*tracepointNames, ",") { + flags.TracepointsToAttach = extractTracepointFlags(tracepointsToAttach) + flags.TracepointsToExclude = extractTracepointFlags(tracepointsToExclude) + + return flags +} + +func extractTracepointFlags(tracepoints *string) (regexes []*regexp.Regexp) { + for _, name := range strings.Split(*tracepoints, ",") { re, err := regexp.Compile(name) if err != nil { fmt.Println("Unable to compile regex", name, ": ", err) os.Exit(2) } - flags.TracepointsToAttach = append(flags.TracepointsToAttach, re) + regexes = append(regexes, re) } - - return flags + return regexes } func (flags Flags) AttachTracepoint(tracepointName string) bool { + for _, re := range flags.TracepointsToExclude { + if re.MatchString(tracepointName) { + return false + } + } if len(flags.TracepointsToAttach) == 0 { return true } diff --git a/internal/flamegraph/iordata.go b/internal/flamegraph/iordata.go index bd0b522..26e5749 100644 --- a/internal/flamegraph/iordata.go +++ b/internal/flamegraph/iordata.go @@ -17,16 +17,13 @@ type commType = string type pidType = uint32 type tidType = uint32 type flagsType = int32 - type pathMap map[pathType]map[traceIdType]map[commType]map[pidType]map[tidType]map[flagsType]counter +type iorData struct{ paths pathMap } -type iorData struct { - paths pathMap -} - -func newIorData() iorData { - return iorData{paths: make(pathMap)} -} +# TODO: Flag to enable iorData +# TODO: Name flag for iorData +# TODO: Output path for iorData flag +func newIorData() iorData { return iorData{paths: make(pathMap)} } func (id iorData) addPath(path pathType, traceId traceIdType, comm commType, pid pidType, tid tidType, flags flagsType, cnt counter) { if _, ok := id.paths[path]; !ok { diff --git a/internal/flamegraph/worker.go b/internal/flamegraph/worker.go index 7c8d848..d10e0bf 100644 --- a/internal/flamegraph/worker.go +++ b/internal/flamegraph/worker.go @@ -10,14 +10,14 @@ import ( type worker struct { collapsed collapsed - data iorData + id iorData done chan struct{} } func newWorker() worker { return worker{ collapsed: make(collapsed), // TODO: Retire - data: newIorData(), // TODO: Implement fully + id: newIorData(), // TODO: Implement fully } } |
