Module: Strumbar::Instrumentation::ActionController

Defined in:
lib/strumbar/instrumentation/action_controller.rb

Class Method Summary collapse

Class Method Details

.load(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/strumbar/instrumentation/action_controller.rb', line 4

def self.load(options={})
  options[:rate] ||= Strumbar.default_rate
  using_mongoid = options.fetch(:mongoid, false)

  Strumbar.subscribe /process_action.action_controller/ do |client, event|
    key = "#{event.payload[:controller]}.#{event.payload[:action]}"
    db_runtime_key = using_mongoid ? :mongo_runtime : :db_runtime

    client.timing     "#{key}.total_time", event.duration, options[:rate]
    client.timing     "#{key}.view_time",  event.payload[:view_runtime], options[:rate]
    client.timing     "#{key}.db_time",    event.payload[db_runtime_key], options[:rate]

    client.increment  "#{key}.status.#{event.payload[:status]}", options[:rate]
  end
end