class ScoutApm::BackgroundRecorder
Attributes
context[R]
queue[R]
thread[R]
Public Class Methods
new(context)
click to toggle source
# File lib/scout_apm/background_recorder.rb, line 12 def initialize(context) @context = context @queue = Queue.new end
Public Instance Methods
logger()
click to toggle source
# File lib/scout_apm/background_recorder.rb, line 17 def logger context.logger end
record!(request)
click to toggle source
# File lib/scout_apm/background_recorder.rb, line 31 def record!(request) start unless @thread.alive? @queue.push(request) end
start()
click to toggle source
# File lib/scout_apm/background_recorder.rb, line 21 def start logger.info("Starting BackgroundRecorder") @thread = Thread.new(&method(:thread_func)) self end
stop()
click to toggle source
# File lib/scout_apm/background_recorder.rb, line 27 def stop @thread.kill end
thread_func()
click to toggle source
# File lib/scout_apm/background_recorder.rb, line 36 def thread_func while req = queue.pop begin logger.debug("recording in thread. Queue size: #{queue.size}") # For now, just proxy right back into the TrackedRequest object's record function req.record! rescue => e logger.warn("Error in BackgroundRecorder - #{e.message} : #{e.backtrace}") end end end