Class: AppPerfRpm::Reporters::JsonClient
- Inherits:
-
Object
- Object
- AppPerfRpm::Reporters::JsonClient
- Defined in:
- lib/app_perf_rpm/reporters/json_client.rb
Instance Method Summary collapse
-
#initialize(opts = { :url => nil, :collector => nil, :flush_interval => nil }) ⇒ JsonClient
constructor
A new instance of JsonClient.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(opts = { :url => nil, :collector => nil, :flush_interval => nil }) ⇒ JsonClient
Returns a new instance of JsonClient.
10 11 12 13 14 |
# File 'lib/app_perf_rpm/reporters/json_client.rb', line 10 def initialize(opts = { :url => nil, :collector => nil, :flush_interval => nil }) @collector = opts[:collector] @flush_interval = opts[:flush_interval] @spans_uri = URI.parse(opts[:url]) end |
Instance Method Details
#start ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/app_perf_rpm/reporters/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/app_perf_rpm/reporters/json_client.rb', line 25 def stop @thread.terminate if @thread emit_batch(@collector.retrieve) end |