diff --git a/lib/datadog/core/diagnostics/environment_logger.rb b/lib/datadog/core/diagnostics/environment_logger.rb index 178621abc55..22b6cd4a30d 100644 --- a/lib/datadog/core/diagnostics/environment_logger.rb +++ b/lib/datadog/core/diagnostics/environment_logger.rb @@ -61,7 +61,6 @@ module EnvironmentLogger def self.collect_and_log! log_once! do data = EnvironmentCollector.collect_config! - data.reject! { |_, v| v.nil? } # Remove empty values from hash output log_configuration!('CORE', data.to_json) end rescue => e diff --git a/lib/datadog/profiling/component.rb b/lib/datadog/profiling/component.rb index 0dd6bd59772..4213403794e 100644 --- a/lib/datadog/profiling/component.rb +++ b/lib/datadog/profiling/component.rb @@ -8,6 +8,9 @@ module Component # * Code Hotspots panel in the trace viewer, as well as scoping a profile down to a span # * Endpoint aggregation in the profiler UX, including normalization (resource per endpoint call) def self.build_profiler_component(settings:, agent_settings:, optional_tracer:) # rubocop:disable Metrics/MethodLength + require_relative '../profiling/diagnostics/environment_logger' + Profiling::Diagnostics::EnvironmentLogger.collect_and_log! + return unless settings.profiling.enabled # Workaround for weird dependency direction: the Core::Configuration::Components class currently has a @@ -101,8 +104,6 @@ def self.build_profiler_component(settings:, agent_settings:, optional_tracer:) transport = build_profiler_transport(settings, agent_settings) scheduler = Profiling::Scheduler.new(exporter: exporter, transport: transport) - Profiling::Diagnostics::EnvironmentLogger.collect_and_log! - Profiling::Profiler.new([collector], scheduler) end diff --git a/lib/datadog/profiling/diagnostics/environment_logger.rb b/lib/datadog/profiling/diagnostics/environment_logger.rb index 0228a5717ac..dd3ef4bf55d 100644 --- a/lib/datadog/profiling/diagnostics/environment_logger.rb +++ b/lib/datadog/profiling/diagnostics/environment_logger.rb @@ -15,7 +15,6 @@ module EnvironmentLogger def self.collect_and_log! log_once! do data = EnvironmentCollector.collect_config! - data.reject! { |_, v| v.nil? } # Remove empty values from hash output log_configuration!('PROFILING', data.to_json) end rescue => e diff --git a/lib/datadog/tracing/diagnostics/environment_logger.rb b/lib/datadog/tracing/diagnostics/environment_logger.rb index db1c507d87e..af84bdf6b42 100644 --- a/lib/datadog/tracing/diagnostics/environment_logger.rb +++ b/lib/datadog/tracing/diagnostics/environment_logger.rb @@ -15,7 +15,6 @@ module EnvironmentLogger def self.collect_and_log!(responses: nil) log_once! do env_data = EnvironmentCollector.collect_config! - env_data.reject! { |_, v| v.nil? } # Remove empty values from hash output log_configuration!('TRACING', env_data.to_json) if responses diff --git a/spec/datadog/core/diagnostics/environment_logger_spec.rb b/spec/datadog/core/diagnostics/environment_logger_spec.rb index d7098684ad0..320426104e9 100644 --- a/spec/datadog/core/diagnostics/environment_logger_spec.rb +++ b/spec/datadog/core/diagnostics/environment_logger_spec.rb @@ -41,8 +41,11 @@ 'version' => DDTrace::VERSION::STRING, 'lang' => 'ruby', 'lang_version' => match(/[23]\./), + 'env' => nil, 'service' => be_a(String), + 'dd_version' => nil, 'debug' => false, + 'tags' => nil, 'runtime_metrics_enabled' => false, 'vm' => be_a(String), 'health_metrics_enabled' => false, diff --git a/spec/datadog/tracing/diagnostics/environment_logger_spec.rb b/spec/datadog/tracing/diagnostics/environment_logger_spec.rb index 783eea9b078..cd5f3ba8cc5 100644 --- a/spec/datadog/tracing/diagnostics/environment_logger_spec.rb +++ b/spec/datadog/tracing/diagnostics/environment_logger_spec.rb @@ -38,9 +38,12 @@ expect(logger).to have_received(:info).with start_with('DATADOG CONFIGURATION - TRACING') do |msg| json = JSON.parse(msg.partition('- TRACING -')[2].strip) expect(json).to match( + 'enabled' => true, 'agent_url' => start_with("http://#{agent_hostname}:#{agent_port}?timeout="), 'analytics_enabled' => false, - 'enabled' => true, + 'sample_rate' => nil, + 'sampling_rules' => nil, + 'integrations_loaded' => nil, 'partial_flushing_enabled' => false, 'priority_sampling_enabled' => false, )