Skip to content

Commit 99a261a

Browse files
committed
Add output configuration
1 parent 72e42aa commit 99a261a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

internal/test/runner/main.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
func main() {
2323
logLevel := flag.String("log-level", "debug", `logging level ("debug", "info", "warn", "error")`)
2424
binPath := flag.String("bin", "", "Path to the target binary")
25+
outPath := flag.String("out", "traces.json", "Path to out generated traces")
2526
flag.Parse()
2627

2728
logger := newLogger(*logLevel)
@@ -36,7 +37,7 @@ func main() {
3637
defer stop()
3738

3839
app := App{logger: logger}
39-
if err := app.Run(ctx, *binPath); err != nil {
40+
if err := app.Run(ctx, *binPath, *outPath); err != nil {
4041
logger.Error("failed to run", "error", err)
4142
os.Exit(1)
4243
}
@@ -66,8 +67,8 @@ type App struct {
6667
logger *slog.Logger
6768
}
6869

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)
7172
if err != nil {
7273
return err
7374
}
@@ -128,13 +129,13 @@ func (a *App) Run(ctx context.Context, binPath string) error {
128129
return inst.Close()
129130
}
130131

131-
func (a *App) newExporter(ctx context.Context) (trace.SpanExporter, error) {
132+
func (a *App) newExporter(ctx context.Context, outPath string) (trace.SpanExporter, error) {
132133
f := fileexporter.NewFactory()
133134
factory, err := collex.NewFactory(f, nil)
134135
if err != nil {
135136
return nil, err
136137
}
137138
c := f.CreateDefaultConfig().(*fileexporter.Config)
138-
c.Path = "traces.json"
139+
c.Path = outPath
139140
return factory.SpanExporter(ctx, c)
140141
}

0 commit comments

Comments
 (0)