lib/httpx/adapters/datadog.rb in httpx-1.3.0 vs lib/httpx/adapters/datadog.rb in httpx-1.3.1

- old
+ new

@@ -193,17 +193,21 @@ # handles the case when the +error+ happened during name resolution, which meanns # that the tracing logic hasn't been injected yet; in such cases, the approximate # initial resolving time is collected from the connection, and used as span start time, # and the tracing object in inserted before the on response callback is called. - def handle_error(error) + def handle_error(error, request = nil) return super unless Datadog::Tracing.enabled? return super unless error.respond_to?(:connection) - @pending.each do |request| - RequestTracer.new(request).call(error.connection.init_time) + @pending.each do |req| + next if request and request == req + + RequestTracer.new(req).call(error.connection.init_time) end + + RequestTracer.new(request).call(error.connection.init_time) if request super end end end