@@ -22,6 +22,7 @@ import (
22
22
func main () {
23
23
logLevel := flag .String ("log-level" , "debug" , `logging level ("debug", "info", "warn", "error")` )
24
24
binPath := flag .String ("bin" , "" , "Path to the target binary" )
25
+ outPath := flag .String ("out" , "traces.json" , "Path to out generated traces" )
25
26
flag .Parse ()
26
27
27
28
logger := newLogger (* logLevel )
@@ -36,7 +37,7 @@ func main() {
36
37
defer stop ()
37
38
38
39
app := App {logger : logger }
39
- if err := app .Run (ctx , * binPath ); err != nil {
40
+ if err := app .Run (ctx , * binPath , * outPath ); err != nil {
40
41
logger .Error ("failed to run" , "error" , err )
41
42
os .Exit (1 )
42
43
}
@@ -66,8 +67,8 @@ type App struct {
66
67
logger * slog.Logger
67
68
}
68
69
69
- func (a * App ) Run (ctx context.Context , binPath string ) error {
70
- exp , err := a .newExporter (ctx )
70
+ func (a * App ) Run (ctx context.Context , binPath , outPath string ) error {
71
+ exp , err := a .newExporter (ctx , outPath )
71
72
if err != nil {
72
73
return err
73
74
}
@@ -128,13 +129,13 @@ func (a *App) Run(ctx context.Context, binPath string) error {
128
129
return inst .Close ()
129
130
}
130
131
131
- func (a * App ) newExporter (ctx context.Context ) (trace.SpanExporter , error ) {
132
+ func (a * App ) newExporter (ctx context.Context , outPath string ) (trace.SpanExporter , error ) {
132
133
f := fileexporter .NewFactory ()
133
134
factory , err := collex .NewFactory (f , nil )
134
135
if err != nil {
135
136
return nil , err
136
137
}
137
138
c := f .CreateDefaultConfig ().(* fileexporter.Config )
138
- c .Path = "traces.json"
139
+ c .Path = outPath
139
140
return factory .SpanExporter (ctx , c )
140
141
}
0 commit comments