-
Notifications
You must be signed in to change notification settings - Fork 22k
Add ActiveSupport::Notification to Channel::Base#perform_action #23723
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
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
dispatch_action(action, data) | ||
else | ||
logger.error "Unable to process #{action_signature(action, data)}" | ||
ActiveSupport::Notifications.instrument("perform_action.action_cable", action: action, data: data) do |
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.
This should go inside the conditional, right above the dispatch method. Wouldn't we only want to send out notifications for actions that can be processed?
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.
It's updated. Thanks for pointing that out!
Since you are here could you do the same in the transmit* calls? and move the |
Sure, I'd be happy to @rafaelfranca. |
Thank you so much! |
@@ -166,6 +166,21 @@ def rm_rf | |||
end | |||
end | |||
|
|||
test "notification for perform_action" do | |||
events = [] | |||
ActiveSupport::Notifications.subscribe "perform_action.action_cable" do |*args| |
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.
We need to unsubscribe in a ensure
block.
9163fa7
to
0d1972c
Compare
It appears that the last commit did not trigger CI for some reason. The |
Can you squash down your commits? |
33e9029
to
040a462
Compare
Awesome work! |
136f4ec
to
9c1dd02
Compare
@@ -160,7 +161,10 @@ def perform_action(data) | |||
action = extract_action(data) | |||
|
|||
if processable_action?(action) | |||
dispatch_action(action, data) | |||
payload = {channel_class: self.class.name, action: action, data: data} |
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.
Can you add spaces and after the brackets?
{ channel_class: self.class.name, action: action, data: data }
A few small code styling comments, otherwise this looks really good! :) |
9c1dd02
to
27011da
Compare
Thanks for the feedback! I've updated the PR with your comments. |
This commit adds ActiveSupport::Notifications instrumentation hooks and a LogSuscriber to ActionCable::Channel::Base.
27011da
to
09a1321
Compare
@rafaelfranca I was wondering if this is still targeted for 5.0.0? |
Yes it is. I found some problems with how Action Cable logging interact with tagged logs and how it would work with the LoggerSubscriber and I was going to address it before merging. I probably will do it tomorrow. |
Great, thanks for the update! |
Add ActiveSupport::Notification to Channel::Base#perform_action
It would be nice for
ActionCable::Channel::Base#perform_action
to have anActiveSupport::Notifications
instrumentation hook similar toActionController#process_action
This PR adds an ActiveSupport::Notification hook to ActionCable Channel::Base#perform_action. The payload contains the action and the data passed to perform action.