lib/async/http/client.rb in async-http-0.82.1 vs lib/async/http/client.rb in async-http-0.82.2

- old
+ new

@@ -99,11 +99,11 @@ attempt += 1 # As we cache pool, it's possible these pool go bad (e.g. closed by remote host). In this case, we need to try again. It's up to the caller to impose a timeout on this. If this is the last attempt, we force a new connection. connection = @pool.acquire - response = make_response(request, connection) + response = make_response(request, connection, attempt) # This signals that the ensure block below should not try to release the connection, because it's bound into the response which will be returned: connection = nil return response rescue Protocol::RequestFailed @@ -138,10 +138,40 @@ def inspect "#<#{self.class} authority=#{@authority.inspect}>" end + protected + + def make_response(request, connection, attempt) + response = request.call(connection) + + response.pool = @pool + + return response + end + + def assign_default_tags(tags) + tags[:endpoint] = @endpoint.to_s + tags[:protocol] = @protocol.to_s + end + + def make_pool(**options) + if connection_limit = options.delete(:connection_limit) + warn "The connection_limit: option is deprecated, please use limit: instead.", uplevel: 2 + options[:limit] = connection_limit + end + + self.assign_default_tags(options[:tags] ||= {}) + + Async::Pool::Controller.wrap(**options) do + Console.logger.debug(self) {"Making connection to #{@endpoint.inspect}"} + + @protocol.client(@endpoint.connect) + end + end + Traces::Provider(self) do def call(request) attributes = { 'http.method': request.method, 'http.authority': request.authority || self.authority, @@ -176,38 +206,18 @@ span["http.response.length"] = length end end end end - end - - protected - - def make_response(request, connection) - response = request.call(connection) - response.pool = @pool - - return response - end - - def assign_default_tags(tags) - tags[:endpoint] = @endpoint.to_s - tags[:protocol] = @protocol.to_s - end - - def make_pool(**options) - if connection_limit = options.delete(:connection_limit) - warn "The connection_limit: option is deprecated, please use limit: instead.", uplevel: 2 - options[:limit] = connection_limit - end - - self.assign_default_tags(options[:tags] ||= {}) - - Async::Pool::Controller.wrap(**options) do - Console.logger.debug(self) {"Making connection to #{@endpoint.inspect}"} + def make_response(request, connection, attempt) + attributes = { + attempt: attempt, + } - @protocol.client(@endpoint.connect) + Traces.trace("async.http.client.make_response", attributes: attributes) do + super + end end end end end end