Skip to content
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

tracing: add support for using multiple tracers #979

Closed
tsandall opened this issue Oct 2, 2018 · 1 comment
Closed

tracing: add support for using multiple tracers #979

tsandall opened this issue Oct 2, 2018 · 1 comment

Comments

@tsandall
Copy link
Member

tsandall commented Oct 2, 2018

The current topdown.Query interface only allows callers to supply one tracer at a time. This is fine for simple cases but it has some limitations. For example, if a user wants to enable tracing and profiling, they can't.

We could extend topdown.Query (and rego.Rego) to support multiple tracers by maintaining a set of tracers in the implementation instead of a single one. For example:

r := rego.New(rego.Tracer(tracer1), rego.Tracer(tracer2), ...)
r.Eval(ctx)
// do something with tracer1
// do something with tracer2

The same applies to topdown.Query:

q := topdown.NewQuery(ast.MustParseQuery("true")).WithTracer(tracer1).WithTracer(tracer2)
rs, err := q.Run()
// do something with tracer1
// do something with tracer2

This could be used immediately in the REPL as well as the eval and test subcommands where profiling and coverage may be used in conjunction with tracing (respectively).

@tsandall
Copy link
Member Author

This was fixed in f79b301

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant