Module: HoneycombRails::Overrides::ActionControllerInstrumentation

Defined in:
lib/honeycomb-rails/overrides/action_controller_instrumentation.rb

Instance Method Summary collapse

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?
    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



58
59
60
61
62
63
64
65
66
# File 'lib/honeycomb-rails/overrides/action_controller_instrumentation.rb', line 58

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
  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_metadataObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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 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_deviseObject



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/honeycomb-rails/overrides/action_controller_instrumentation.rb', line 46

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