Skip to content

Commit 18d4a91

Browse files
committed
Add support for instrumentation tags.
1 parent 0eb1c3d commit 18d4a91

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

async-http.gemspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ Gem::Specification.new do |spec|
2525
spec.required_ruby_version = ">= 3.1"
2626

2727
spec.add_dependency "async", ">= 2.10.2"
28-
spec.add_dependency "async-pool", "~> 0.7"
29-
spec.add_dependency "io-endpoint", "~> 0.11"
28+
spec.add_dependency "async-pool", "~> 0.9"
29+
spec.add_dependency "io-endpoint", "~> 0.14"
3030
spec.add_dependency "io-stream", "~> 0.4"
3131
spec.add_dependency "protocol-http", "~> 0.37"
3232
spec.add_dependency "protocol-http1", "~> 0.27"
3333
spec.add_dependency "protocol-http2", "~> 0.19"
34-
spec.add_dependency "traces", ">= 0.10"
34+
spec.add_dependency "traces", "~> 0.10"
35+
spec.add_dependency "metrics", "~> 0.12"
3536
end

lib/async/http/client.rb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
module Async
1919
module HTTP
2020
DEFAULT_RETRIES = 3
21-
DEFAULT_CONNECTION_LIMIT = nil
2221

2322
class Client < ::Protocol::HTTP::Methods
2423
# Provides a robust interface to a server.
@@ -30,12 +29,12 @@ class Client < ::Protocol::HTTP::Methods
3029
# @param protocol [Protocol::HTTP1 | Protocol::HTTP2 | Protocol::HTTPS] the protocol to use.
3130
# @param scheme [String] The default scheme to set to requests.
3231
# @param authority [String] The default authority to set to requests.
33-
def initialize(endpoint, protocol: endpoint.protocol, scheme: endpoint.scheme, authority: endpoint.authority, retries: DEFAULT_RETRIES, connection_limit: DEFAULT_CONNECTION_LIMIT)
32+
def initialize(endpoint, protocol: endpoint.protocol, scheme: endpoint.scheme, authority: endpoint.authority, retries: DEFAULT_RETRIES, **options)
3433
@endpoint = endpoint
3534
@protocol = protocol
3635

3736
@retries = retries
38-
@pool = make_pool(connection_limit)
37+
@pool = make_pool(**options)
3938

4039
@scheme = scheme
4140
@authority = authority
@@ -191,8 +190,20 @@ def make_response(request, connection)
191190
return response
192191
end
193192

194-
def make_pool(connection_limit)
195-
Async::Pool::Controller.wrap(limit: connection_limit) do
193+
def assign_default_tags(tags)
194+
tags[:endpoint] = @endpoint.to_s
195+
tags[:protocol] = @protocol.to_s
196+
end
197+
198+
def make_pool(**options)
199+
if connection_limit = options.delete(:connection_limit)
200+
warn "The connection_limit: option is deprecated, please use limit: instead.", uplevel: 2
201+
options[:limit] = connection_limit
202+
end
203+
204+
self.assign_default_tags(options[:tags] ||= {})
205+
206+
Async::Pool::Controller.wrap(**options) do
196207
Console.logger.debug(self) {"Making connection to #{@endpoint.inspect}"}
197208

198209
@protocol.client(@endpoint.connect)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy