Class: OpenTrace::RuntimeMonitor

Inherits:
Object
  • Object
show all
Defined in:
lib/opentrace/runtime_monitor.rb

Constant Summary collapse

DEFAULT_INTERVAL =

seconds

30

Instance Method Summary collapse

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

Returns:

  • (Boolean)


26
27
28
# File 'lib/opentrace/runtime_monitor.rb', line 26

def running?
  @running && @thread&.alive?
end

#startObject



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

#stopObject



21
22
23
24
# File 'lib/opentrace/runtime_monitor.rb', line 21

def stop
  @running = false
  @thread&.join(2)
end