Class: Zipkin::JsonClient

Inherits:
Object
  • Object
show all
Defined in:
lib/zipkin/json_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(url:, collector:, flush_interval:) ⇒ JsonClient

Returns a new instance of JsonClient.



7
8
9
10
11
# File 'lib/zipkin/json_client.rb', line 7

def initialize(url:, collector:, flush_interval:)
  @collector = collector
  @flush_interval = flush_interval
  @spans_uri = URI.parse("#{url}/api/v1/spans")
end

Instance Method Details

#startObject



13
14
15
16
17
18
19
20
# File 'lib/zipkin/json_client.rb', line 13

def start
  @thread = Thread.new do
    loop do
      emit_batch(@collector.retrieve)
      sleep @flush_interval
    end
  end
end

#stopObject



22
23
24
25
# File 'lib/zipkin/json_client.rb', line 22

def stop
  @thread.terminate if @thread
  emit_batch(@collector.retrieve)
end