diff options
Diffstat (limited to 'internal/flamegraph')
| -rw-r--r-- | internal/flamegraph/recorder.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/flamegraph/recorder.go b/internal/flamegraph/recorder.go new file mode 100644 index 0000000..432e509 --- /dev/null +++ b/internal/flamegraph/recorder.go @@ -0,0 +1,34 @@ +package flamegraph + +import "ior/internal/event" + +// Recorder aggregates event pairs and writes them to the legacy .ior.zst format. +// Integration tests still use this artifact to assert trace output end-to-end. +type Recorder struct { + name string + data iorData +} + +// NewRecorder creates a recorder for one trace run. +func NewRecorder(name string) *Recorder { + return &Recorder{ + name: name, + data: newIorData(), + } +} + +// AddPair folds one traced syscall pair into the aggregated output. +func (r *Recorder) AddPair(pair *event.Pair) { + if r == nil || pair == nil { + return + } + r.data.addEventPair(pair) +} + +// Write persists the aggregated trace output to a .ior.zst file. +func (r *Recorder) Write() error { + if r == nil { + return nil + } + return r.data.serializeToFile(r.name) +} |
