Skip to content

Commit

Permalink
Revert profiling back to using the agent_settings generated in Datado…
Browse files Browse the repository at this point in the history
…g::Core::Configuration::Components.initalize (#3082)

* Revert profiling back to using the agent_settings generated in
Datadog::Core::Configuration::Components.initalize instead of building
its own as per @ivoanjo request.
  • Loading branch information
ekump authored Aug 29, 2023
1 parent bae2327 commit 1990eb7
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 33 deletions.
1 change: 0 additions & 1 deletion Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ target :ddtrace do
ignore 'lib/datadog/opentracer/thread_local_scope.rb'
ignore 'lib/datadog/opentracer/thread_local_scope_manager.rb'
ignore 'lib/datadog/opentracer/tracer.rb'
ignore 'lib/datadog/profiling/agent_settings_resolver.rb'
ignore 'lib/datadog/profiling/backtrace_location.rb'
ignore 'lib/datadog/profiling/buffer.rb'
ignore 'lib/datadog/profiling/collectors/code_provenance.rb'
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/core/configuration/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def initialize(settings)

@profiler = Datadog::Profiling::Component.build_profiler_component(
settings: settings,
logger: @logger,
agent_settings: agent_settings,
optional_tracer: @tracer,
)
@runtime_metrics = self.class.build_runtime_metrics_worker(settings)
Expand Down
11 changes: 0 additions & 11 deletions lib/datadog/profiling/agent_settings_resolver.rb

This file was deleted.

5 changes: 1 addition & 4 deletions lib/datadog/profiling/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ module Component
# Passing in a `nil` tracer is supported and will disable the following profiling features:
# * 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:, logger:, optional_tracer:) # rubocop:disable Metrics/MethodLength
def self.build_profiler_component(settings:, agent_settings:, optional_tracer:) # rubocop:disable Metrics/MethodLength
require_relative '../profiling/diagnostics/environment_logger'
require_relative '../profiling/agent_settings_resolver'

Profiling::Diagnostics::EnvironmentLogger.collect_and_log!

Expand Down Expand Up @@ -102,8 +101,6 @@ def self.build_profiler_component(settings:, logger:, optional_tracer:) # ruboco
timeline_enabled: timeline_enabled,
}.freeze

agent_settings = Datadog::Profiling::AgentSettingsResolver.call(settings, logger: logger)

exporter = build_profiler_exporter(settings, recorder, internal_metadata: internal_metadata)
transport = build_profiler_transport(settings, agent_settings)
scheduler = Profiling::Scheduler.new(exporter: exporter, transport: transport)
Expand Down
6 changes: 0 additions & 6 deletions sig/datadog/profiling/agent_settings_resolver.rbs

This file was deleted.

2 changes: 1 addition & 1 deletion sig/datadog/profiling/component.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Datadog
module Component
def self.build_profiler_component: (
settings: untyped,
logger: untyped,
agent_settings: Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings,
optional_tracer: Datadog::Tracing::Tracer?,
) -> Datadog::Profiling::Profiler?

Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/core/configuration/components_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

expect(Datadog::Profiling::Component).to receive(:build_profiler_component).with(
settings: settings,
logger: logger,
agent_settings: agent_settings,
optional_tracer: tracer,
).and_return(profiler)

Expand Down
9 changes: 2 additions & 7 deletions spec/datadog/profiling/component_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
require 'datadog/profiling/spec_helper'
require 'datadog/profiling/agent_settings_resolver'

RSpec.describe Datadog::Profiling::Component do
let(:settings) { Datadog::Core::Configuration::Settings.new }
let(:logger) { nil }
let(:agent_settings) { Datadog::Profiling::AgentSettingsResolver.call(settings, logger: logger) }
let(:agent_settings) { Datadog::Core::Configuration::AgentSettingsResolver.call(settings, logger: logger) }
let(:profiler_setup_task) { instance_double(Datadog::Profiling::Tasks::Setup) if Datadog::Profiling.supported? }

before do
Expand All @@ -18,7 +17,7 @@
let(:tracer) { instance_double(Datadog::Tracing::Tracer) }

subject(:build_profiler_component) do
described_class.build_profiler_component(settings: settings, logger: logger, optional_tracer: tracer)
described_class.build_profiler_component(settings: settings, agent_settings: agent_settings, optional_tracer: tracer)
end

context 'when profiling is not supported' do
Expand Down Expand Up @@ -49,10 +48,6 @@

settings.profiling.enabled = true
allow(profiler_setup_task).to receive(:run)

expect(Datadog::Profiling::AgentSettingsResolver).to receive(:call)
.with(settings, logger: logger)
.and_return(agent_settings)
end

context 'when using the legacy profiler' do
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/profiling/http_transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
end

let(:agent_settings) do
Datadog::Profiling::AgentSettingsResolver::AgentSettings.new(
Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings.new(
adapter: adapter,
uds_path: uds_path,
ssl: ssl,
Expand Down

0 comments on commit 1990eb7

Please sign in to comment.