Class: Zipkin::JsonClient
- Inherits:
-
Object
- Object
- Zipkin::JsonClient
- Defined in:
- lib/zipkin/json_client.rb
Instance Method Summary collapse
-
#initialize(url:, collector:, flush_interval:, logger: Logger.new(STDOUT)) ⇒ JsonClient
constructor
A new instance of JsonClient.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(url:, collector:, flush_interval:, logger: Logger.new(STDOUT)) ⇒ JsonClient
Returns a new instance of JsonClient.
9 10 11 12 13 14 |
# File 'lib/zipkin/json_client.rb', line 9 def initialize(url:, collector:, flush_interval:, logger: Logger.new(STDOUT)) @collector = collector @flush_interval = flush_interval @spans_uri = URI.parse("#{url}/api/v2/spans") @logger = logger end |
Instance Method Details
#start ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/zipkin/json_client.rb', line 16 def start @thread = Thread.new do loop do emit_batch(@collector.retrieve) sleep @flush_interval end end end |
#stop ⇒ Object
25 26 27 28 |
# File 'lib/zipkin/json_client.rb', line 25 def stop @thread.terminate if @thread emit_batch(@collector.retrieve) end |