Method: OneApm::Collector::Commands::XraySessionCollection#initialize

Defined in:
lib/one_apm/collector/commands/xray_session_collection.rb

#initialize(backtrace_service, event_listener) ⇒ XraySessionCollection

Returns a new instance of XraySessionCollection.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/one_apm/collector/commands/xray_session_collection.rb', line 13

def initialize(backtrace_service, event_listener)
  @backtrace_service = backtrace_service

  # This lock protects access to the sessions hash, but it's expected
  # that individual session objects within the hash will be manipulated
  # outside the lock.  This is safe because manipulation of the session
  # objects is expected from only a single thread (the harvest thread)
  @sessions_lock = Mutex.new
  @sessions = {}

  if event_listener
    event_listener.subscribe(:before_harvest, &method(:cleanup_finished_sessions))
  end
end