Class: Datadog::Profiling::Profiler

Inherits:
Object
  • Object
show all
Includes:
Core::Utils::Forking
Defined in:
lib/datadog/profiling/profiler.rb

Overview

Profiling entry point, which coordinates the worker and scheduler threads

Instance Method Summary collapse

Methods included from Core::Utils::Forking

#after_fork!, extended, #fork_pid, #forked?, included, #update_fork_pid!

Constructor Details

#initialize(worker:, scheduler:) ⇒ Profiler

Returns a new instance of Profiler.



13
14
15
16
# File 'lib/datadog/profiling/profiler.rb', line 13

def initialize(worker:, scheduler:)
  @worker = worker
  @scheduler = scheduler
end

Instance Method Details

#shutdown!Object



28
29
30
31
32
33
# File 'lib/datadog/profiling/profiler.rb', line 28

def shutdown!
  Datadog.logger.debug('Shutting down profiler')

  stop_worker
  stop_scheduler
end

#startObject



18
19
20
21
22
23
24
25
26
# File 'lib/datadog/profiling/profiler.rb', line 18

def start
  after_fork! do
    worker.reset_after_fork
    scheduler.reset_after_fork
  end

  worker.start(on_failure_proc: proc { component_failed(:worker) })
  scheduler.start(on_failure_proc: proc { component_failed(:scheduler) })
end