diff options
Diffstat (limited to 'internal/flamegraph')
| -rw-r--r-- | internal/flamegraph/flamegraph.go | 4 | ||||
| -rw-r--r-- | internal/flamegraph/iordata.go | 15 |
2 files changed, 6 insertions, 13 deletions
diff --git a/internal/flamegraph/flamegraph.go b/internal/flamegraph/flamegraph.go index 9e1e14b..aeb5143 100644 --- a/internal/flamegraph/flamegraph.go +++ b/internal/flamegraph/flamegraph.go @@ -18,7 +18,7 @@ type Flamegraph struct { workers []worker } -func New(flags flags.Flags) Flamegraph { +func New() Flamegraph { f := Flamegraph{ Ch: make(chan *event.Pair, 4096), Done: make(chan struct{}), @@ -41,7 +41,7 @@ func (f Flamegraph) Start(ctx context.Context) { for i, worker := range f.workers { fmt.Println("Starting flamegraph worker", i) - if f.flags.FlamegraphName == "" { // Empty string means: old style collapsed + if flags.Get().FlamegraphName == "" { // Empty string means: old style collapsed go worker.runCollapsed(ctx, &wg, f.Ch) } else { go worker.run(ctx, &wg, f.Ch) diff --git a/internal/flamegraph/iordata.go b/internal/flamegraph/iordata.go index c167f22..b6bb197 100644 --- a/internal/flamegraph/iordata.go +++ b/internal/flamegraph/iordata.go @@ -21,7 +21,6 @@ type flagsType = string type pathMap map[pathType]map[traceIdType]map[commType]map[pidType]map[tidType]map[flagsType]counter type iorData struct { - flags flags.Flags paths pathMap } @@ -29,11 +28,8 @@ type iorData struct { // TODO: Name flag for iorData (outfile format: hostname-name-timestamp.ior.zst) // TODO: Output path for iorData flag // TODO: Add helper to convert .ior data file to collapsed format -func newIorData(flags flags.Flags) iorData { - return iorData{ - flags: flags, - paths: make(pathMap), - } +func newIorData() iorData { + return iorData{paths: make(pathMap)} } // TODO: Unit test @@ -100,7 +96,7 @@ func (iod iorData) commit() error { panic(err) } - filename := fmt.Sprintf("%s-%s-%s.ior.zst", hostname, iod.flags.FlamegraphName, + filename := fmt.Sprintf("%s-%s-%s.ior.zst", hostname, flags.Get().FlamegraphName, time.Now().Format("2006-01-02_15:04:05")) file, err := os.Create(filename) if err != nil { @@ -108,10 +104,7 @@ func (iod iorData) commit() error { } defer file.Close() - encoder, err := zstd.NewWriter(file) - if err != nil { - return err - } + encoder := zstd.NewWriter(file) defer encoder.Close() jsonEncoder := json.NewEncoder(encoder) |
