From baa571f248040306263338388a2c3ab7072b379d Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Mon, 13 Jan 2025 15:20:01 -0500 Subject: [PATCH] DEBUG-3328 log probe installation and DI payload submission to agent for debugging --- lib/datadog/di.rb | 4 ++++ lib/datadog/di/contrib.rb | 2 ++ lib/datadog/di/probe_manager.rb | 2 ++ lib/datadog/di/probe_notifier_worker.rb | 1 + 4 files changed, 9 insertions(+) diff --git a/lib/datadog/di.rb b/lib/datadog/di.rb index ff185b09318..67ee4c1b8bb 100644 --- a/lib/datadog/di.rb +++ b/lib/datadog/di.rb @@ -58,6 +58,10 @@ def component # # If DI is enabled programmatically, the application can (and must, # for line probes to work) activate tracking in an initializer. + if %w'1 true debug'.include?(ENV['DD_TRACE_DEBUG']) + # We seem to have Datadog.logger here already + Datadog.logger.debug("di: activating code tracking") + end 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..9cca7e86484 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 #{probe.id}" } true rescue Error::DITargetNotDefined @pending_probes[probe.id] = probe + logger.debug { "di: could not install #{probe.type} probe #{probe.id} 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..454594a1237 100644 --- a/lib/datadog/di/probe_notifier_worker.rb +++ b/lib/datadog/di/probe_notifier_worker.rb @@ -234,6 +234,7 @@ def set_sleep_remaining end if batch.any? # steep:ignore begin + logger.debug { "di: sending #{batch.length} #{event_type} payloads to agent" } transport.public_send("send_#{event_type}", batch) time = Core::Utils::Time.get_time @lock.synchronize do