Open DanielGilchrist opened 2 years ago
Hello! Wouldn't you achieve the same by using the Prosopite.raise setter?
def _raise_on_n_plus_ones
Prosopite.raise = true
yield
ensure
Prosopite.raise = false
end
The setter should probably be modified to be thread safe though.
Hello! Wouldn't you achieve the same by using the Prosopite.raise setter?
def _raise_on_n_plus_ones Prosopite.raise = true yield ensure Prosopite.raise = false end
The setter should probably be modified to be thread safe though.
Thank you for your response and sorry for the late reply!
The main reason is that the current implementation of Prosopite.raise
doesn't work well for multi-threaded applications or between requests (in our case a Rails application) as it's an instance variable on the class itself. This works great for initial setup but could lead to confusing behaviour when set dynamically on the class
Happy to look into moving to a Prosopite.raise
focused API if you think that would be more suitable
@charkost is there anything we can do to nudge this PR along? 🙏
Hello and thank you for this gem!
I'm in the process of integrating Prosopite into our Rails codebase and we're going for an incremental approach by setting
Prosopite.raise = false
during configuration to avoid disrupting development. The problem for us with this is we also want to be able to raise on specific actions / controllers once N+1s have been eliminated from them with an around action. We considered setting config to always raise and only setting the around action for controllers / actions with N+1s resolved but we're also really keen on keeping the logs for existing N+1sHere's an example of it's usage in a Rails app where
Prosopite.raise
is set tofalse
:Please let me know if you'd prefer a different API or anything else and I'll fix it up, thanks!