Skip to content

Commit

Permalink
use uds
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed Oct 24, 2024
1 parent dcda9d0 commit f2b4b4b
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions lib/datadog/core/configuration/agent_settings_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f2b4b4b

Please sign in to comment.