summaryrefslogtreecommitdiff
path: root/internal/eventloop.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-03-29 18:19:06 +0200
committerPaul Buetow <paul@buetow.org>2025-03-29 18:19:06 +0200
commitb8ac7c88b203ba5475cbca63669ce654c2ed49ea (patch)
tree3fc6d2539ced1d4012f9bf0fe69d4d191e2a5049 /internal/eventloop.go
parentdc5c405f6afb9fc59ba73e7dbc7cd3564983ae6e (diff)
flags is now a singleton
Diffstat (limited to 'internal/eventloop.go')
-rw-r--r--internal/eventloop.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/internal/eventloop.go b/internal/eventloop.go
index 4e9a3cb..f52274d 100644
--- a/internal/eventloop.go
+++ b/internal/eventloop.go
@@ -20,7 +20,6 @@ import (
// TOOD: read and write syscalls: can also collect amount of bytes!
type eventLoop struct {
- flags flags.Flags
filter *eventFilter
enterEvs map[uint32]*event.Pair // Temp. store of sys_enter tracepoints per Tid.
files map[int32]file.File // Track all open files by file descriptor..
@@ -37,15 +36,14 @@ type eventLoop struct {
done chan struct{}
}
-func newEventLoop(flags flags.Flags) *eventLoop {
+func newEventLoop() *eventLoop {
return &eventLoop{
- flags: flags,
- filter: newEventFilter(flags),
+ filter: newEventFilter(),
enterEvs: make(map[uint32]*event.Pair),
files: make(map[int32]file.File),
comms: make(map[uint32]string),
prevPairTimes: make(map[uint32]uint64),
- flamegraph: flamegraph.New(flags),
+ flamegraph: flamegraph.New(),
done: make(chan struct{}),
}
}
@@ -73,23 +71,23 @@ func (e *eventLoop) stats() string {
func (e *eventLoop) run(ctx context.Context, rawCh <-chan []byte) {
defer close(e.done)
- if e.flags.FlamegraphEnable {
+ if flags.Get().FlamegraphEnable {
fmt.Println("Collecting flame graph stats, press Ctrl+C to stop")
e.flamegraph.Start(ctx)
}
- if e.flags.PprofEnable {
+ if flags.Get().PprofEnable {
fmt.Println("Profiling, press Ctrl+C to stop")
}
- if !e.flags.FlamegraphEnable && !e.flags.PprofEnable {
+ if !flags.Get().FlamegraphEnable && !flags.Get().PprofEnable {
fmt.Println(event.EventStreamHeader)
}
e.startTime = time.Now()
for ev := range e.events(ctx, rawCh) {
switch {
- case e.flags.FlamegraphEnable:
+ case flags.Get().FlamegraphEnable:
e.flamegraph.Ch <- ev
- case e.flags.PprofEnable:
+ case flags.Get().PprofEnable:
ev.Recycle()
default:
fmt.Println(ev.String())
@@ -98,7 +96,7 @@ func (e *eventLoop) run(ctx context.Context, rawCh <-chan []byte) {
e.numSyscallsAfterFilter++
}
- if e.flags.FlamegraphEnable {
+ if flags.Get().FlamegraphEnable {
fmt.Println("Waiting for flamegraph")
<-e.flamegraph.Done
}