From f3ba0c1dd32821ad700b2784d160d1c161fb3125 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Wed, 11 May 2016 16:55:17 -0700 Subject: Add ActiveSupport::Notifications hook to Broadcaster#broadcast This addition of this notification hook will give users better visibility into the messages being sent over the PubSub adapter. --- actioncable/lib/action_cable/server/broadcasting.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'actioncable/lib/action_cable') diff --git a/actioncable/lib/action_cable/server/broadcasting.rb b/actioncable/lib/action_cable/server/broadcasting.rb index 8f93564113..1fc58baa3e 100644 --- a/actioncable/lib/action_cable/server/broadcasting.rb +++ b/actioncable/lib/action_cable/server/broadcasting.rb @@ -39,8 +39,12 @@ module ActionCable def broadcast(message) server.logger.info "[ActionCable] Broadcasting to #{broadcasting}: #{message.inspect}" - encoded = coder ? coder.encode(message) : message - server.pubsub.broadcast broadcasting, encoded + + payload = { broadcasting: broadcasting, message: message, coder: coder } + ActiveSupport::Notifications.instrument("broadcast.action_cable", payload) do + encoded = coder ? coder.encode(message) : message + server.pubsub.broadcast broadcasting, encoded + end end end end -- cgit v1.2.3