Class: Jaeger::Samplers::RemoteControlled::InstructionsFetcher
- Inherits:
-
Object
- Object
- Jaeger::Samplers::RemoteControlled::InstructionsFetcher
- Defined in:
- lib/jaeger/samplers/remote_controlled/instructions_fetcher.rb
Constant Summary collapse
- FetchFailed =
Class.new(StandardError)
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(host:, port:, service_name:) ⇒ InstructionsFetcher
constructor
A new instance of InstructionsFetcher.
Constructor Details
#initialize(host:, port:, service_name:) ⇒ InstructionsFetcher
Returns a new instance of InstructionsFetcher.
9 10 11 12 13 |
# File 'lib/jaeger/samplers/remote_controlled/instructions_fetcher.rb', line 9 def initialize(host:, port:, service_name:) @host = host @port = port @service_name = service_name end |
Instance Method Details
#fetch ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jaeger/samplers/remote_controlled/instructions_fetcher.rb', line 15 def fetch http = Net::HTTP.new(@host, @port) path = "/sampling?service=#{CGI.escape(@service_name)}" response = begin http.request(Net::HTTP::Get.new(path)) rescue StandardError => e raise FetchFailed, e.inspect end unless response.is_a?(Net::HTTPSuccess) raise FetchFailed, "Unsuccessful response (code=#{response.code})" end JSON.parse(response.body) end |