From f2b4b4b4e052b76a7b5db7a03e8946907c942aba Mon Sep 17 00:00:00 2001 From: Munir Abdinur Date: Thu, 24 Oct 2024 10:05:08 -0400 Subject: [PATCH] use uds --- .../configuration/agent_settings_resolver.rb | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/lib/datadog/core/configuration/agent_settings_resolver.rb b/lib/datadog/core/configuration/agent_settings_resolver.rb index 057f5285d14..93592404380 100644 --- a/lib/datadog/core/configuration/agent_settings_resolver.rb +++ b/lib/datadog/core/configuration/agent_settings_resolver.rb @@ -232,7 +232,26 @@ def uds_fallback end def should_use_uds? - can_use_uds? && !mixed_http_and_uds? + # When we have mixed settings for http/https and uds, we print a warning + # and use the uds settings. + unless defined?(@mixed_http_and_uds) + @mixed_http_and_uds = (configured_hostname || configured_port) && can_use_uds? + if @mixed_http_and_uds + warn_if_configuration_mismatch( + [ + DetectedConfiguration.new( + friendly_name: 'configuration of hostname/port for http/https use', + value: "hostname: '#{hostname}', port: '#{port}'", + ), + DetectedConfiguration.new( + friendly_name: 'configuration for unix domain socket', + value: parsed_url.to_s, + ), + ] + ) + end + end + can_use_uds? end def can_use_uds? @@ -307,30 +326,6 @@ def unix_scheme?(uri) uri.scheme == 'unix' end - # When we have mixed settings for http/https and uds, we print a warning and ignore the uds settings - def mixed_http_and_uds? - return @mixed_http_and_uds if defined?(@mixed_http_and_uds) - - @mixed_http_and_uds = (configured_hostname || configured_port) && can_use_uds? - - if @mixed_http_and_uds - warn_if_configuration_mismatch( - [ - DetectedConfiguration.new( - friendly_name: 'configuration of hostname/port for http/https use', - value: "hostname: '#{hostname}', port: '#{port}'", - ), - DetectedConfiguration.new( - friendly_name: 'configuration for unix domain socket', - value: parsed_url.to_s, - ), - ] - ) - end - - @mixed_http_and_uds - end - # Represents a given configuration value and where we got it from class DetectedConfiguration attr_reader :friendly_name, :value