Class: OpenTrace::QueueMonitor
- Inherits:
-
Object
- Object
- OpenTrace::QueueMonitor
- Defined in:
- lib/opentrace/queue_monitor.rb
Constant Summary collapse
- DEFAULT_INTERVAL =
seconds
60
Instance Method Summary collapse
-
#initialize(interval: DEFAULT_INTERVAL) ⇒ QueueMonitor
constructor
A new instance of QueueMonitor.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(interval: DEFAULT_INTERVAL) ⇒ QueueMonitor
Returns a new instance of QueueMonitor.
7 8 9 10 11 |
# File 'lib/opentrace/queue_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/queue_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_queue_stats rescue Exception # rubocop:disable Lint/RescueException # Swallow end end end |
#stop ⇒ Object
29 30 31 32 |
# File 'lib/opentrace/queue_monitor.rb', line 29 def stop @running = false @thread&.join(2) end |