Sha256: a1434134c2d78f8e73ba30a7b26f7da8741394c5c38b0729e8256f758c530434
Contents?: true
Size: 1.94 KB
Versions: 3
Compression:
Stored size: 1.94 KB
Contents
# frozen_string_literal: true module Datadog module Profiling # Profiling entry point, which coordinates the worker and scheduler threads class Profiler include Datadog::Core::Utils::Forking private attr_reader :worker, :scheduler, :optional_crashtracker public def initialize(worker:, scheduler:, optional_crashtracker:) @worker = worker @scheduler = scheduler @optional_crashtracker = optional_crashtracker end def start after_fork! do optional_crashtracker.reset_after_fork if optional_crashtracker worker.reset_after_fork scheduler.reset_after_fork end optional_crashtracker.start if optional_crashtracker worker.start(on_failure_proc: proc { component_failed(:worker) }) scheduler.start(on_failure_proc: proc { component_failed(:scheduler) }) end def shutdown! Datadog.logger.debug('Shutting down profiler') stop_worker stop_scheduler optional_crashtracker.stop if optional_crashtracker end private def stop_worker worker.stop end def stop_scheduler scheduler.enabled = false scheduler.stop(true) end def component_failed(failed_component) Datadog.logger.warn( "Detected issue with profiler (#{failed_component} component), stopping profiling. " \ 'See previous log messages for details.' ) # We explicitly not stop the crash tracker in this situation, under the assumption that, if a component failed, # we're operating in a degraded state and crash tracking may still be helpful. if failed_component == :worker stop_scheduler elsif failed_component == :scheduler stop_worker else raise ArgumentError, "Unexpected failed_component: #{failed_component.inspect}" end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
datadog-2.2.0 | lib/datadog/profiling/profiler.rb |
datadog-2.1.0 | lib/datadog/profiling/profiler.rb |
datadog-2.0.0 | lib/datadog/profiling/profiler.rb |