mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-09-25 00:01:20 -04:00
Compare commits
No commits in common. "master" and "v1.6.1" have entirely different histories.
@ -180,7 +180,7 @@ module Datadog::Tracing
|
|||||||
end
|
end
|
||||||
|
|
||||||
module RequestMethods
|
module RequestMethods
|
||||||
attr_accessor :init_time
|
attr_reader :init_time
|
||||||
|
|
||||||
# intercepts request initialization to inject the tracing logic.
|
# intercepts request initialization to inject the tracing logic.
|
||||||
def initialize(*)
|
def initialize(*)
|
||||||
@ -193,30 +193,26 @@ module Datadog::Tracing
|
|||||||
RequestTracer.call(self)
|
RequestTracer.call(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def response=(*)
|
def response=(response)
|
||||||
# init_time should be set when it's send to a connection.
|
if response.is_a?(::HTTPX::ErrorResponse) && response.error.respond_to?(:connection)
|
||||||
# However, there are situations where connection initialization fails.
|
# handles the case when the +error+ happened during name resolution, which means
|
||||||
# Example is the :ssrf_filter plugin, which raises an error on
|
# that the tracing start point hasn't been triggered yet; in such cases, the approximate
|
||||||
# initialize if the host is an IP which matches against the known set.
|
# initial resolving time is collected from the connection, and used as span start time,
|
||||||
# in such cases, we'll just set here right here.
|
# and the tracing object in inserted before the on response callback is called.
|
||||||
@init_time ||= ::Datadog::Core::Utils::Time.now.utc
|
@init_time = response.error.connection.init_time
|
||||||
|
end
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module ConnectionMethods
|
module ConnectionMethods
|
||||||
|
attr_reader :init_time
|
||||||
|
|
||||||
def initialize(*)
|
def initialize(*)
|
||||||
super
|
super
|
||||||
|
|
||||||
@init_time = ::Datadog::Core::Utils::Time.now.utc
|
@init_time = ::Datadog::Core::Utils::Time.now.utc
|
||||||
end
|
end
|
||||||
|
|
||||||
def send(request)
|
|
||||||
request.init_time ||= @init_time
|
|
||||||
|
|
||||||
super
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -243,10 +243,6 @@ module HTTPX
|
|||||||
case @state
|
case @state
|
||||||
when :idle
|
when :idle
|
||||||
connect
|
connect
|
||||||
|
|
||||||
# when opening the tcp or ssl socket fails
|
|
||||||
return if @state == :closed
|
|
||||||
|
|
||||||
consume
|
consume
|
||||||
when :closed
|
when :closed
|
||||||
return
|
return
|
||||||
|
@ -69,11 +69,11 @@ module HTTPX
|
|||||||
addresses = @resolver_options[:cache] && (connection.addresses || HTTPX::Resolver.nolookup_resolve(hostname))
|
addresses = @resolver_options[:cache] && (connection.addresses || HTTPX::Resolver.nolookup_resolve(hostname))
|
||||||
return false unless addresses
|
return false unless addresses
|
||||||
|
|
||||||
ip_families = connection.options.ip_families
|
ip_families = connection.options.ip_families || Resolver.supported_ip_families
|
||||||
|
|
||||||
resolved = false
|
resolved = false
|
||||||
addresses.group_by(&:family).sort { |(f1, _), (f2, _)| f2 <=> f1 }.each do |family, addrs|
|
addresses.group_by(&:family).sort { |(f1, _), (f2, _)| f2 <=> f1 }.each do |family, addrs|
|
||||||
next unless ip_families.nil? || ip_families.include?(family)
|
next unless ip_families.include?(family)
|
||||||
|
|
||||||
# try to match the resolver by family. However, there are cases where that's not possible, as when
|
# try to match the resolver by family. However, there are cases where that's not possible, as when
|
||||||
# the system does not have IPv6 connectivity, but it does support IPv6 via loopback/link-local.
|
# the system does not have IPv6 connectivity, but it does support IPv6 via loopback/link-local.
|
||||||
@ -91,7 +91,11 @@ module HTTPX
|
|||||||
end
|
end
|
||||||
|
|
||||||
def lazy_resolve(connection)
|
def lazy_resolve(connection)
|
||||||
|
ip_families = connection.options.ip_families || Resolver.supported_ip_families
|
||||||
|
|
||||||
@resolvers.each do |resolver|
|
@resolvers.each do |resolver|
|
||||||
|
next unless ip_families.include?(resolver.family)
|
||||||
|
|
||||||
resolver << @current_session.try_clone_connection(connection, @current_selector, resolver.family)
|
resolver << @current_session.try_clone_connection(connection, @current_selector, resolver.family)
|
||||||
next if resolver.empty?
|
next if resolver.empty?
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user