Skip to content

Instantly share code, notes, and snippets.

@romatr
Created April 4, 2014 12:31
Show Gist options
  • Save romatr/9973731 to your computer and use it in GitHub Desktop.
Save romatr/9973731 to your computer and use it in GitHub Desktop.
Request and session object to be available in Rail notifications payload
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