Created
April 4, 2014 12:31
-
-
Save romatr/9973731 to your computer and use it in GitHub Desktop.
Request and session object to be available in Rail notifications payload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionController::Instrumentation.class_eval do | |
def process_action(*args) | |
raw_payload = { | |
controller: self.class.name, | |
action: self.action_name, | |
params: request.filtered_parameters, | |
format: request.format.try(:ref), | |
method: request.method, | |
path: (request.fullpath rescue "unknown"), | |
request: request, | |
session: session | |
} | |
ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload.dup) | |
ActiveSupport::Notifications.instrument("process_action.action_controller", raw_payload) do |payload| | |
result = super | |
payload[:status] = response.status | |
append_info_to_payload(payload) | |
result | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment