Class: EventMachine::Monitor
- Inherits:
-
Object
- Object
- EventMachine::Monitor
- Defined in:
- lib/em-monitor.rb
Overview
The monitor object itself deals with maintaining lspace and timers.
Constant Summary collapse
- DEFAULT_INTERVAL =
How long (by default) between calls to monitors
60
- DEFAULT_BUCKETS =
Which buckets to include in the histogram by default
[0.001, 0.01, 0.1, 1, 10]
Instance Method Summary collapse
-
#initialize(&block) {|self| ... } ⇒ Monitor
constructor
Create a new monitor.
-
#monitor_spans(interval, &block) {|spans, from, to| ... } ⇒ Object
Attach a listener to this monitor.
Constructor Details
#initialize(&block) {|self| ... } ⇒ Monitor
Create a new monitor.
The block will be called in the monitor’s LSpace, all further EM work should happen within the block to ensure that we measure everything.
145 146 147 148 149 |
# File 'lib/em-monitor.rb', line 145 def initialize(&block) create_lspace.enter do block.call self end end |
Instance Method Details
#monitor_spans(interval, &block) {|spans, from, to| ... } ⇒ Object
Attach a listener to this monitor.
Only one listener can be active at a time, and the interval set here will take affect after the next tick of the previous interval.
162 163 164 165 166 |
# File 'lib/em-monitor.rb', line 162 def monitor_spans(interval, &block) @periodic_timer ||= create_timer(interval) @periodic_timer.interval = interval @monitor = block end |