Class: SenorArmando::Plugins::StatsdPlugin
- Inherits:
-
Object
- Object
- SenorArmando::Plugins::StatsdPlugin
- Defined in:
- lib/senor_armando/plugins/statsd_plugin.rb
Overview
Sends metrics to a remote statsd-compatible server
You might also enjoy using the SenorArmando::Rack::StatsdLogger middleware.
Constant Summary collapse
- @@recent_latency =
0
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(port, config, status, logger) ⇒ SenorArmando::Plugins::StatsdPlugin
constructor
Called by the framework to initialize the plugin.
-
#run ⇒ Object
Called automatically to start the plugin.
Constructor Details
#initialize(port, config, status, logger) ⇒ SenorArmando::Plugins::StatsdPlugin
Called by the framework to initialize the plugin
63 64 65 66 67 68 69 |
# File 'lib/senor_armando/plugins/statsd_plugin.rb', line 63 def initialize(port, config, status, logger) @status = status @config = config[:statsd_logger] || {} @config[:logger] = logger @last = Time.now.to_f end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
54 55 56 |
# File 'lib/senor_armando/plugins/statsd_plugin.rb', line 54 def agent @agent end |
Class Method Details
.agent ⇒ Object
80 81 82 |
# File 'lib/senor_armando/plugins/statsd_plugin.rb', line 80 def self.agent @@agent end |
.recent_latency ⇒ Object
72 73 74 |
# File 'lib/senor_armando/plugins/statsd_plugin.rb', line 72 def self.recent_latency @@recent_latency end |
Instance Method Details
#run ⇒ Object
Called automatically to start the plugin
85 86 87 88 89 90 91 92 |
# File 'lib/senor_armando/plugins/statsd_plugin.rb', line 85 def run agent EM.add_periodic_timer(1) do @@recent_latency = (Time.now.to_f - @last) agent.timing 'reactor.latency', @@recent_latency @last = Time.now.to_f end end |