Skip to content

Commit

Permalink
Merge pull request #3057 from DataDog/refactor/extract_environment_lo…
Browse files Browse the repository at this point in the history
…gger_3

EnvironmentLogger adjustments
  • Loading branch information
sarahchen6 authored Aug 17, 2023
2 parents d4d3cc9 + 6d35cad commit 0e7da21
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion lib/datadog/core/diagnostics/environment_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions lib/datadog/profiling/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion lib/datadog/profiling/diagnostics/environment_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/datadog/tracing/diagnostics/environment_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions spec/datadog/core/diagnostics/environment_logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion spec/datadog/tracing/diagnostics/environment_logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down

0 comments on commit 0e7da21

Please sign in to comment.