Class: OpenTrace::RuntimeMonitor
- Inherits:
-
Object
- Object
- OpenTrace::RuntimeMonitor
- Defined in:
- lib/opentrace/runtime_monitor.rb
Constant Summary collapse
- DEFAULT_INTERVAL =
seconds
30
Instance Method Summary collapse
-
#initialize(interval: DEFAULT_INTERVAL) ⇒ RuntimeMonitor
constructor
A new instance of RuntimeMonitor.
- #running? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(interval: DEFAULT_INTERVAL) ⇒ RuntimeMonitor
Returns a new instance of RuntimeMonitor.
7 8 9 10 11 |
# File 'lib/opentrace/runtime_monitor.rb', line 7 def initialize(interval: DEFAULT_INTERVAL) @interval = interval @thread = nil @running = false end |
Instance Method Details
#running? ⇒ Boolean
26 27 28 |
# File 'lib/opentrace/runtime_monitor.rb', line 26 def running? @running && @thread&.alive? end |
#start ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/opentrace/runtime_monitor.rb', line 13 def start return if @running @running = true @thread = Thread.new { monitor_loop } @thread.abort_on_exception = false @thread.report_on_exception = false end |
#stop ⇒ Object
21 22 23 24 |
# File 'lib/opentrace/runtime_monitor.rb', line 21 def stop @running = false @thread&.join(2) end |