Class: ActionController::StatsSubscriber
- Inherits:
-
ActiveSupport::Subscriber
- Object
- ActiveSupport::Subscriber
- ActionController::StatsSubscriber
- Defined in:
- lib/gremlin/railtie.rb
Instance Method Summary collapse
- #action_controller_process_action_count ⇒ Object
- #action_controller_process_action_db_runtime_ms ⇒ Object
- #action_controller_process_action_total_runtime_ms ⇒ Object
- #action_controller_process_action_view_runtime_ms ⇒ Object
- #action_controller_start_processing_count ⇒ Object
- #basic_labels ⇒ Object
- #notification_count ⇒ Object
- #process_action(event) ⇒ Object
- #start_processing(event) ⇒ Object
Instance Method Details
#action_controller_process_action_count ⇒ Object
45 46 47 48 49 |
# File 'lib/gremlin/railtie.rb', line 45 def action_controller_process_action_count @process_action_count ||= Gremlin.registry.register Gremlin::Instruments::Counter.new("action_controller_process_action_count", "Count of process_action.action_controller notifications handled by Gremlin.", basic_labels) end |
#action_controller_process_action_db_runtime_ms ⇒ Object
57 58 59 60 61 |
# File 'lib/gremlin/railtie.rb', line 57 def action_controller_process_action_db_runtime_ms @process_action_db_runtime ||= Gremlin.registry.register Gremlin::Instruments::Summary.new("action_controller_process_action_db_runtime_ms", "ActionController process action db runtime in milliseconds.", basic_labels) end |
#action_controller_process_action_total_runtime_ms ⇒ Object
63 64 65 66 67 |
# File 'lib/gremlin/railtie.rb', line 63 def action_controller_process_action_total_runtime_ms @process_action_total_runtime ||= Gremlin.registry.register Gremlin::Instruments::Summary.new("action_controller_process_action_total_runtime_ms", "ActionController process action total runtime in milliseconds.", basic_labels) end |
#action_controller_process_action_view_runtime_ms ⇒ Object
51 52 53 54 55 |
# File 'lib/gremlin/railtie.rb', line 51 def action_controller_process_action_view_runtime_ms @process_action_view_runtime ||= Gremlin.registry.register Gremlin::Instruments::Summary.new("action_controller_process_action_view_runtime_ms", "ActionController process action view runtime in milliseconds.", basic_labels) end |
#action_controller_start_processing_count ⇒ Object
39 40 41 42 43 |
# File 'lib/gremlin/railtie.rb', line 39 def action_controller_start_processing_count @start_processing_count ||= Gremlin.registry.register Gremlin::Instruments::Counter.new("action_controller_start_processing_count", "Count of start_processing.action_controller notifications handled by Gremlin.", basic_labels) end |
#basic_labels ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/gremlin/railtie.rb', line 25 def basic_labels environment = ::Rails.env.to_s application_name = ::Rails.application.class.parent_name.downcase node = `hostname`.strip { node: node, app: application_name, env: environment } end |
#notification_count ⇒ Object
33 34 35 36 37 |
# File 'lib/gremlin/railtie.rb', line 33 def notification_count @notification_count ||= Gremlin.registry.register Gremlin::Instruments::Counter.new("notification_count", "Count of notifications handled by Gremlin.", basic_labels) end |
#process_action(event) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/gremlin/railtie.rb', line 69 def process_action(event) return if Gremlin.disabled? notification_count.increment action_controller_process_action_count.increment({ controller: event.payload[:controller].to_s, format: event.payload[:format].to_s, action: event.payload[:action], status: event.payload[:status] }) begin action_controller_process_action_view_runtime_ms.observe({ controller: event.payload[:controller], method: event.payload[:method], status: event.payload[:status], action: event.payload[:action] }, event.payload[:view_runtime] ) rescue; end begin action_controller_process_action_db_runtime_ms.observe({ controller: event.payload[:controller], method: event.payload[:method], status: event.payload[:status], action: event.payload[:action] }, event.payload[:db_runtime] ) rescue; end begin action_controller_process_action_total_runtime_ms.observe({ controller: event.payload[:controller], method: event.payload[:method], status: event.payload[:status], action: event.payload[:action] }, event.duration ) rescue; end end |
#start_processing(event) ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'lib/gremlin/railtie.rb', line 106 def start_processing(event) return if Gremlin.disabled? notification_count.increment action_controller_start_processing_count.increment({ controller: event.payload[:controller].to_s, format: event.payload[:format].to_s, action: event.payload[:action] }) end |