Method: NewRelic::Agent::Commands::AgentCommandRouter#initialize

Defined in:
lib/new_relic/agent/commands/agent_command_router.rb

#initialize(event_listener = nil) ⇒ AgentCommandRouter

Returns a new instance of AgentCommandRouter.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/new_relic/agent/commands/agent_command_router.rb', line 22

def initialize(event_listener = nil)
  @handlers = Hash.new { |*| proc { |cmd| self.unrecognized_agent_command(cmd) } }

  @backtrace_service = Threading::BacktraceService.new(event_listener)

  @thread_profiler_session = ThreadProfilerSession.new(@backtrace_service)

  @handlers['start_profiler'] = proc { |cmd| thread_profiler_session.handle_start_command(cmd) }
  @handlers['stop_profiler'] = proc { |cmd| thread_profiler_session.handle_stop_command(cmd) }

  # the following statement needs else branch coverage
  if event_listener # rubocop:disable Style/SafeNavigation
    event_listener.subscribe(:before_shutdown, &method(:on_before_shutdown))
  end
end