Skip to content

Commit

Permalink
pass agent_settings to the transport from the outside instead of tryi…
Browse files Browse the repository at this point in the history
…ng to resolve it internally again
  • Loading branch information
anmarchenko committed Jul 22, 2024
1 parent ff8ffb8 commit 3ad1c69
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/datadog/core/configuration/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def build_telemetry(settings, agent_settings, logger)
dd_site: settings.site
)
else
Datadog::Core::Telemetry::Http::Transport.build_agent_transport
Datadog::Core::Telemetry::Http::Transport.build_agent_transport(agent_settings)
end

Telemetry::Component.new(
Expand Down
4 changes: 1 addition & 3 deletions lib/datadog/core/telemetry/http/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ module Http
# Class to send telemetry data to Telemetry API
# Currently only supports the HTTP protocol.
class Transport
def self.build_agent_transport
agent_settings = Configuration::AgentSettingsResolver.call(Datadog.configuration)

def self.build_agent_transport(agent_settings)
Transport.new(
host: agent_settings.hostname,
port: agent_settings.port,
Expand Down
7 changes: 6 additions & 1 deletion spec/datadog/core/configuration/components_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,12 @@
dependency_collection: dependency_collection, shutdown_timeout_seconds: shutdown_timeout_seconds }
end
let(:agent_settings) do
instance_double(Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings, adapter: :unix)
instance_double(
Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings,
adapter: :unix,
hostname: 'foo',
port: 1234
)
end

it 'does not enable telemetry for unsupported non-http transport' do
Expand Down
3 changes: 2 additions & 1 deletion spec/datadog/core/telemetry/http/transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
require 'datadog/core/telemetry/http/adapters/net'

RSpec.describe Datadog::Core::Telemetry::Http::Transport do
subject(:transport) { described_class.build_agent_transport }
subject(:transport) { described_class.build_agent_transport(agent_settings) }

let(:agent_settings) { Datadog::Core::Configuration::AgentSettingsResolver.call(Datadog.configuration) }
let(:hostname) { 'foo' }
let(:port) { 1234 }

Expand Down

0 comments on commit 3ad1c69

Please sign in to comment.