Sha256: b9880dc9def41fa857d956da97af30d11a494c705d737255f900c27f83e9b662

Contents?: true

Size: 736 Bytes

Versions: 3

Compression:

Stored size: 736 Bytes

Contents

require 'rails'

module PulseToolbox
  module Sensor
    # Registeres an initializer which creates sensors and subscribes to
    # process_action.action_controller notification
    class Initializer < ::Rails::Railtie
      initializer "register_request_sensors", after: :load_config_initializers do
        if PulseToolbox.redis
          ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, start, finish, id, payload|
            total_time = (finish - start) * 1000
            PulseToolbox::Sensor::Manager.log_request(total_time, payload)
          end
        else
          Rails.logger.error("PulseToolbox.redis is not defined. Sensors cannot be created")
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pulse-meter-rails-0.1.4 lib/pulse_toolbox/sensor/initializer.rb
pulse-meter-rails-0.1.3 lib/pulse_toolbox/sensor/initializer.rb
pulse-meter-rails-0.1.2 lib/pulse_toolbox/sensor/initializer.rb