module HoneycombRails::Overrides::ActionControllerInstrumentation
Public Instance Methods
append_info_to_payload(payload)
click to toggle source
Calls superclass method
# File lib/honeycomb-rails/overrides/action_controller_instrumentation.rb, line 7 def append_info_to_payload(payload) super metadata = honeycomb_metadata || {} metadata.merge!(honeycomb_user_metadata) if HoneycombRails.config.record_flash? && respond_to?(:flash) flash.each do |k, v| metadata[:"flash_#{k}"] = v end end # Attach to ActiveSupport::Instrumentation payload for consumption by # subscribers/process_action.rb payload[Constants::EVENT_METADATA_KEY] = metadata end
honeycomb_detect_user_methods!()
click to toggle source
# File lib/honeycomb-rails/overrides/action_controller_instrumentation.rb, line 72 def honeycomb_detect_user_methods! if respond_to?(:current_user) # This could be more sophisticated, but it'll do for now HoneycombRails.config.record_user = :devise elsif respond_to?(:current_api_user) HoneycombRails.config.record_user = :devise_api else logger.error "HoneycombRails.config.record_user = :detect but couldn't detect user methods; disabling user recording." HoneycombRails.config.record_user = false end end
honeycomb_user_metadata()
click to toggle source
# File lib/honeycomb-rails/overrides/action_controller_instrumentation.rb, line 25 def honeycomb_user_metadata if defined?(@honeycomb_user_proc) return @honeycomb_user_proc.call(self) end case HoneycombRails.config.record_user when :detect honeycomb_detect_user_methods! honeycomb_user_metadata when :devise honeycomb_user_metadata_devise when :devise_api honeycomb_user_metadata_devise_api when Proc @honeycomb_user_proc = HoneycombRails.config.record_user honeycomb_user_metadata when nil, false {} else raise "Invalid value for HoneycombRails.config.record_user: #{HoneycombRails.config.record_user.inspect}" end end
honeycomb_user_metadata_devise()
click to toggle source
# File lib/honeycomb-rails/overrides/action_controller_instrumentation.rb, line 48 def honeycomb_user_metadata_devise if respond_to?(:current_user) and current_user { current_user_id: current_user.id, current_user_email: current_user.email, current_user_admin: !!current_user.try(:admin?), } else {} end end
honeycomb_user_metadata_devise_api()
click to toggle source
# File lib/honeycomb-rails/overrides/action_controller_instrumentation.rb, line 60 def honeycomb_user_metadata_devise_api if respond_to?(:current_api_user) and current_api_user { current_user_id: current_api_user.id, current_user_email: current_api_user.email, current_user_admin: !!current_api_user.try(:admin?), } else {} end end