-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add profile command to REPL #838
Comments
I will take a stab at this one |
okay, so I believe there is small problem. When I look at profiler_test.go it seems to me profiling is enabled by passing it as a buffer to tracer:
This would mean that we can have a tracing(explain) XOR profile. The issue then is that in eval.body we would need to check if tracing and profile are enabled and choose one. It makes sense that when tracing is enabled profile is somewhat useless. https://gist.github.com/repenno/36043a2538ddd0dd71d6c6a74d9cbdbf |
Yes, they're mutually exclusive currently. We need to add support for multiple tracers. We have an open issue for that #979. For now, we could just do some simple toggling (e.g., if profiling is enabled, tracing is turned off, and vice-versa.) |
This is turning out to be much more complicated than I originally thought... In eval.Body I have to do something like this:
because later we call
and when it is time to present actual tracing (not profile) we call
which expects []*topdown.Event and not BufferTracer. I am letting you know so you can comment before I go too far. Otherwise I am chipping at it little by little |
Here's roughly how I'd approach this.
Hope this helps. |
yep, that is what I did, I am trying to hook the results back to the REPL |
If you set the profiler result on the output struct, the presentation package will handle it for you. |
Yes, I did like this:
The issue is that I had to choose defaults for the report function. |
In the |
okay, will use that. Good suggestion |
|
I have hit a snag that I do not know how to solve it since it might be inside the bowels of rego. I am using the same exact example from https://www.openpolicyagent.org/docs/how-do-i-test-policies.html#profiling The issue is that I never get the second part, i.e., the metric-value table
My result is as follows:
Here is the patch https://gist.github.com/repenno/3e68c166f72c44ab672a61932f0da5ab |
Scratch that, I figured it out. eval --profile is turning on metrics under the covers. |
For the time being, enabling profiling will disable tracing and vice versa. Once we add support for multiple tracers, this behavior can be changed. Fixes #838 Signed-off-by: Torin Sandall <torinsandall@gmail.com> Signed-off-by: repenno <rapenno@gmail.com>
Users should be able to enable profiling in the REPL (just like they can enable tracing, metrics, etc.) For example, by entering
profile
in the REPL, the setting is toggled.To get started, take a look at how the
metrics
command is implemented in the REPL. At a high-level here are the pieces that need to be implemented:profile
case to switch statement that handles REPL commandsprofile
entry to command list for help outputThe text was updated successfully, but these errors were encountered: