Class: OpenTrace::PoolMonitor
- Inherits:
-
Object
- Object
- OpenTrace::PoolMonitor
- Defined in:
- lib/opentrace/pool_monitor.rb
Constant Summary collapse
- DEFAULT_INTERVAL =
seconds
30
Instance Method Summary collapse
-
#initialize(interval: DEFAULT_INTERVAL) ⇒ PoolMonitor
constructor
A new instance of PoolMonitor.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(interval: DEFAULT_INTERVAL) ⇒ PoolMonitor
Returns a new instance of PoolMonitor.
7 8 9 10 11 |
# File 'lib/opentrace/pool_monitor.rb', line 7 def initialize(interval: DEFAULT_INTERVAL) @interval = interval @thread = nil @running = false end |
Instance Method Details
#start ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/opentrace/pool_monitor.rb', line 13 def start return if @running @running = true @thread = Thread.new do Thread.current.report_on_exception = false loop do sleep @interval break unless @running report_pool_stats rescue Exception # rubocop:disable Lint/RescueException # Swallow — never crash the host app end end end |
#stop ⇒ Object
29 30 31 32 |
# File 'lib/opentrace/pool_monitor.rb', line 29 def stop @running = false @thread&.join(2) end |