diff --git a/lib/datadog/di.rb b/lib/datadog/di.rb index ff185b09318..e0681e6667e 100644 --- a/lib/datadog/di.rb +++ b/lib/datadog/di.rb @@ -58,6 +58,8 @@ def component # # If DI is enabled programmatically, the application can (and must, # for line probes to work) activate tracking in an initializer. + # We seem to have Datadog.logger here already + Datadog.logger.debug("di: activating code tracking") Datadog::DI.activate_tracking end diff --git a/lib/datadog/di/contrib.rb b/lib/datadog/di/contrib.rb index 8098b5befb0..0352b72b58e 100644 --- a/lib/datadog/di/contrib.rb +++ b/lib/datadog/di/contrib.rb @@ -7,6 +7,7 @@ module DI module Contrib module_function def load_now_or_later if Datadog::Core::Contrib::Rails::Utils.railtie_supported? + Datadog.logger.debug('di: loading contrib/railtie') require_relative 'contrib/railtie' else load_now @@ -18,6 +19,7 @@ module Contrib # dependencies are loaded (or potentially loaded). module_function def load_now if defined?(ActiveRecord::Base) + Datadog.logger.debug('di: loading contrib/active_record') require_relative 'contrib/active_record' end end diff --git a/lib/datadog/di/probe_manager.rb b/lib/datadog/di/probe_manager.rb index 2567eb9803b..9faccbb41d3 100644 --- a/lib/datadog/di/probe_manager.rb +++ b/lib/datadog/di/probe_manager.rb @@ -111,9 +111,11 @@ def add_probe(probe) # Always remove from pending list here because it makes the # API smaller and shouldn't cause any actual problems. @pending_probes.delete(probe.id) + logger.debug { "di: installed #{probe.type} probe at #{probe.location}" } true rescue Error::DITargetNotDefined @pending_probes[probe.id] = probe + logger.debug { "di: could not install #{probe.type} probe at #{probe.location} because its target is not defined, adding it to pending list" } false end rescue => exc diff --git a/lib/datadog/di/probe_notifier_worker.rb b/lib/datadog/di/probe_notifier_worker.rb index 03efaece9e0..ae4703dc64e 100644 --- a/lib/datadog/di/probe_notifier_worker.rb +++ b/lib/datadog/di/probe_notifier_worker.rb @@ -10,7 +10,7 @@ module DI # The loop inside the worker rescues all exceptions to prevent termination # due to unhandled exceptions raised by any downstream code. # This includes communication and protocol errors when sending the - # payloads to the agent. + # events to the agent. # # The worker groups the data to send into batches. The goal is to perform # no more than one network operation per event type per second. @@ -45,6 +45,7 @@ def initialize(settings, transport, logger, telemetry: nil) def start return if @thread + logger.debug("di: starting probe notifier: pid #{$$}") @thread = Thread.new do loop do # TODO If stop is requested, we stop immediately without @@ -94,6 +95,7 @@ def start # to killing the thread using Thread#kill. def stop(timeout = 1) @stop_requested = true + logger.debug("di: stopping probe notifier") wake.signal if thread unless thread.join(timeout) @@ -234,6 +236,7 @@ def set_sleep_remaining end if batch.any? # steep:ignore begin + logger.debug { "di: sending #{batch.length} #{event_type} events to agent" } transport.public_send("send_#{event_type}", batch) time = Core::Utils::Time.get_time @lock.synchronize do diff --git a/lib/datadog/di/remote.rb b/lib/datadog/di/remote.rb index 1e5a0b8aa14..bb455f7352e 100644 --- a/lib/datadog/di/remote.rb +++ b/lib/datadog/di/remote.rb @@ -53,7 +53,7 @@ def receivers(telemetry) payload = probe_notification_builder.build_received(probe) probe_notifier_worker = component.probe_notifier_worker probe_notifier_worker.add_status(payload) - component.logger.debug { "di: received probe from RC: #{probe.type} #{probe.location}" } + component.logger.debug { "di: received probe from RC: #{probe.type} at #{probe.location}" } begin # TODO test exception capture