-
Notifications
You must be signed in to change notification settings - Fork 2.7k
tracegen: add capability to marshal spans to file #7691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
tracegen: add capability to marshal spans to file #7691
Conversation
When you have text |
cmd/tracegen/main.go
Outdated
| if fileWriter != nil { | ||
| return stdouttrace.New( | ||
| stdouttrace.WithWriter(fileWriter), | ||
| stdouttrace.WithPrettyPrint(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need pretty-print for what is meant to be a machine-readable format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, I did it for debugging, but you're right, production doesn't need it
9dcee2c to
bbb5126
Compare
internal/tracegen/config.go
Outdated
| fs.StringVar(&c.Service, "service", "tracegen", "Service name prefix to use") | ||
| fs.IntVar(&c.Services, "services", 1, "Number of unique suffixes to add to service name when generating traces, e.g. tracegen-01 (but only one service per trace)") | ||
| fs.StringVar(&c.TraceExporter, "trace-exporter", "otlp-http", "Trace exporter (otlp/otlp-http|otlp-grpc|stdout). Exporters can be additionally configured via environment variables, see https://github.com/jaegertracing/jaeger/blob/main/cmd/tracegen/README.md") | ||
| fs.StringVar(&c.ExportToFile, "export-to-file", "", "Filename to write generated spans to (in JSON format) instead of sending to a collector") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just thinking - adding this new option creates an ambiguity, which one takes precedence, this one or trace-exporter. We can keep it to a single flag if we allow file:{filename} syntax.
Btw the README incorrectly says the option name is -exporter, can you fix it in the same PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Signed-off-by: Samriddha9619 <[email protected]>
872ebd9 to
8e7c11f
Compare
Which problem is this PR solving?
Description of the changes
-marshal-to-filetointernal/tracegen/config.go.cmd/tracegen/main.goto intercept the exporter creation logic.stdoutexporter is initialized with a customos.Filewriter instead of the defaultos.Stdout.How was this change tested?
./tracegen -marshal-to-file=test.json -traces=1test.jsoncontains valid, clean JSON span data with no log corruption.golangci-linton modified packages (passed).go test ./internal/tracegen/...(passed).Checklist
jaeger:make lint testjaeger-ui:npm run lintandnpm run test