-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
Instrument Reflex processing in development and log a summary #686
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for stimulusreflex ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
39407a0
to
cb32fb5
Compare
Thanks for opening this @Matt-Yorkley, this is great! Would you mind resolving the Standard errors? |
I just ran this in my app and encountered this error when calling a reflex, do you have a hunch what this could be about? Reflex FolderReflex#edit failed: wrong number of arguments (given 5, expected 1) [http://localhost:3000/]
/Users/marcoroth/Development/stimulus_reflex/lib/stimulus_reflex/instrumentation.rb:11:in `block (2 levels) in track'
/Users/marcoroth/.anyenv/envs/rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.7/lib/active_support/notifications/fanout.rb:186:in `finish'
/Users/marcoroth/.anyenv/envs/rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.7/lib/active_support/notifications/fanout.rb:63:in `block in finish'
/Users/marcoroth/.anyenv/envs/rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.7/lib/active_support/notifications/fanout.rb:63:in `each'
/Users/marcoroth/.anyenv/envs/rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.7/lib/active_support/notifications/fanout.rb:63:in `finish'
/Users/marcoroth/.anyenv/envs/rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.7/lib/active_support/notifications/instrumenter.rb:45:in `finish_with_state'
/Users/marcoroth/.anyenv/envs/rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-6.1.7.7/lib/active_support/notifications/instrumenter.rb:30:in `instrument'
/Users/marcoroth/.anyenv/envs/rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-6.1.7.7/lib/active_record/connection_adapters/abstract_adapter.rb:687:in `log' |
Yikes! First thought from eyeballing the stacktrace; is the public interface for I'll take a look... |
It's related to changes in |
cb32fb5
to
1b923b1
Compare
I just tried a quick dirty-downgrade to Rails 6 to check this out and it looks like if the callback passed to |
Thanks for giving this a look @Matt-Yorkley! Seems like that did the trick! The only other thing I noticed is that the log entries can appear out-of-order. But, I'm not sure we can actually do something about this: Do you see a way how we could resolve this? If not, we can probably merge this as-is. |
Are you doing a page morph? It looks like the reflex executes, then a controller instance is handling a page render, then the broadcast is going out via ActionCable? Might be getting a bit philosophical here, but is that order even incorrect? |
b0342b2
to
ac61a2a
Compare
It turns out emitted `render` events from Rails overlap cumulatively if you render a partial in a partial, and there's no nice way to differentiate parent partials from children, so the duration and allocations counts can be way off when the totals from the events are summed. View time can end up being twice as much as the total time, which is obviously impossible. Rails cheats a bit for it's rendering totals by taking the whole page template, but that doesn't work for SR, so allocations and rendering time have to be calculated a bit differently.
ac61a2a
to
876bf7c
Compare
Enhancement
Description
Tracks time spent processing a Reflex and spits out a summary in the logs (in development) on completion, eg:
Why should this be added
It's nice to see the summaries when optimising querying / rendering.
Checklist
Before (wall of text):
After (summaries and newline):