Module: Wildsight::Rails
- Defined in:
- lib/wildsight/rails/railtie.rb,
lib/wildsight/rails/active_record.rb,
lib/wildsight/rails/action_controller.rb
Defined Under Namespace
Modules: ActionController, ActiveRecord Classes: Railtie
Class Method Summary collapse
Class Method Details
.instrument ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/wildsight/rails/railtie.rb', line 4 def self.instrument return if @instrumented @instrumented = true ::AbstractController::Base.class_eval do include Wildsight::Rails::ActionController alias_method :process_action_without_ws, :process_action def wildsight_context @_wildsight_context ||= Wildsight::Rack.detect_context(self.respond_to?(:request) ? request.env : {}) end def process_action(*args) context = Wildsight::Rack.detect_context(self.respond_to?(:request) ? request.env : {}) return process_action_without_ws(*args) unless context if respond_to?(:request) context.data[:rack][:request][:target] = self.class.name + '#' + request.params['action'] context.data[:rack][:request][:method] = request.method context.data[:rack][:request][:path] = request.original_fullpath context.data[:rack][:request][:params] = request.filtered_parameters context.data[:rack][:request][:session] = {id: request.session.id} context.data[:rack][:request][:url] = request.original_url context.data[:rack][:request][:remote] = request.remote_ip end result = context.profiler.duration(:action) { process_action_without_ws(*args) } return result rescue Exception => e raise e end end ::AbstractController::Rendering.class_eval do alias_method :render_without_ws, :render def render(*args, &block) context = Wildsight::Rack.detect_context(self.respond_to?(:request) ? request.env : {}) result = context.profiler.duration(:view) { render_without_ws(*args, &block) } return result end end end |