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.



15
16
17
18
# File 'lib/datadog/profiling/profiler.rb', line 15

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

Instance Method Details

#shutdown!Object



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

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

  stop_worker
  stop_scheduler
end

#startObject



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

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