Module: HoneycombRails::Overrides::ActionControllerInstrumentation
- Defined in:
- lib/honeycomb-rails/overrides/action_controller_instrumentation.rb
Instance Method Summary collapse
- #append_info_to_payload(payload) ⇒ Object
- #honeycomb_detect_user_methods! ⇒ Object
- #honeycomb_user_metadata ⇒ Object
- #honeycomb_user_metadata_devise ⇒ Object
- #honeycomb_user_metadata_devise_api ⇒ Object
Instance Method Details
#append_info_to_payload(payload) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/honeycomb-rails/overrides/action_controller_instrumentation.rb', line 7 def append_info_to_payload(payload) super = || {} .merge!() if HoneycombRails.config.record_flash? && respond_to?(:flash) flash.each do |k, v| [:"flash_#{k}"] = v end end # Attach to ActiveSupport::Instrumentation payload for consumption by # subscribers/process_action.rb payload[Constants::EVENT_METADATA_KEY] = end |
#honeycomb_detect_user_methods! ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# 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 ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/honeycomb-rails/overrides/action_controller_instrumentation.rb', line 25 def if defined?(@honeycomb_user_proc) return @honeycomb_user_proc.call(self) end case HoneycombRails.config.record_user when :detect honeycomb_detect_user_methods! when :devise when :devise_api when Proc @honeycomb_user_proc = HoneycombRails.config.record_user when nil, false {} else raise "Invalid value for HoneycombRails.config.record_user: #{HoneycombRails.config.record_user.inspect}" end end |
#honeycomb_user_metadata_devise ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/honeycomb-rails/overrides/action_controller_instrumentation.rb', line 48 def 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 ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/honeycomb-rails/overrides/action_controller_instrumentation.rb', line 60 def 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 |