Class: Rmetrics::Events

Inherits:
Object
  • Object
show all
Defined in:
lib/rmetrics/events.rb

Overview

Handles action events across rails

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEvents

Returns a new instance of Events.



8
9
10
# File 'lib/rmetrics/events.rb', line 8

def initialize
  @db_client = Rmetrics::Influx.new(Rmetrics.db_config)
end

Instance Attribute Details

#db_clientObject (readonly)

Returns the value of attribute db_client.



6
7
8
# File 'lib/rmetrics/events.rb', line 6

def db_client
  @db_client
end

Instance Method Details

#cable_subscribe_eventsObject



55
56
57
58
59
# File 'lib/rmetrics/events.rb', line 55

def cable_subscribe_events
  Rmetrics.action_cable.each do |action|
    notification_subscription(action.to_s)
  end
end

#controller_subscribe_eventsObject



19
20
21
22
23
# File 'lib/rmetrics/events.rb', line 19

def controller_subscribe_events
  Rmetrics.action_controller.each do |action|
    notification_subscription(action.to_s)
  end
end

#job_subscribe_eventsObject



49
50
51
52
53
# File 'lib/rmetrics/events.rb', line 49

def job_subscribe_events
  Rmetrics.active_job.each do |action|
    notification_subscription(action.to_s)
  end
end

#mailer_subscribe_eventsObject



37
38
39
40
41
# File 'lib/rmetrics/events.rb', line 37

def mailer_subscribe_events
  Rmetrics.action_mailer.each do |action|
    notification_subscription(action.to_s)
  end
end

#notification_subscription(action_name) ⇒ Object



12
13
14
15
16
17
# File 'lib/rmetrics/events.rb', line 12

def notification_subscription(action_name)
  ActiveSupport::Notifications.subscribe(action_name) do |*args|
    event = ActiveSupport::Notifications::Event.new(*args)
    @db_client.write_data(action_name, event)
  end
end

#record_subscribe_eventsObject



31
32
33
34
35
# File 'lib/rmetrics/events.rb', line 31

def record_subscribe_events
  Rmetrics.active_record.each do |action|
    notification_subscription(action.to_s)
  end
end

#storage_subscribe_eventsObject



61
62
63
64
65
# File 'lib/rmetrics/events.rb', line 61

def storage_subscribe_events
  Rmetrics.active_storage.each do |action|
    notification_subscription(action.to_s)
  end
end

#support_subscribe_eventsObject



43
44
45
46
47
# File 'lib/rmetrics/events.rb', line 43

def support_subscribe_events
  Rmetrics.active_support.each do |action|
    notification_subscription(action.to_s)
  end
end

#view_subscribe_eventsObject



25
26
27
28
29
# File 'lib/rmetrics/events.rb', line 25

def view_subscribe_events
  Rmetrics.active_view.each do |action|
    notification_subscription(action.to_s)
  end
end