Class: BaselineRedRpm::Reporters::JsonClient
- Inherits:
-
Object
- Object
- BaselineRedRpm::Reporters::JsonClient
- Defined in:
- lib/baseline_red_rpm/reporters/json_client.rb
Instance Attribute Summary collapse
-
#sample_memory ⇒ Object
Returns the value of attribute sample_memory.
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.
13 14 15 16 17 |
# File 'lib/baseline_red_rpm/reporters/json_client.rb', line 13 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 Attribute Details
#sample_memory ⇒ Object
Returns the value of attribute sample_memory.
11 12 13 |
# File 'lib/baseline_red_rpm/reporters/json_client.rb', line 11 def sample_memory @sample_memory end |
Instance Method Details
#start ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/baseline_red_rpm/reporters/json_client.rb', line 19 def start @thread = Thread.new do loop do memory_stats = MemoryProfiler.stop emit_batch(@collector.retrieve, memory_stats) start_memory_profiler sleep @flush_interval end end end |
#stop ⇒ Object
32 33 34 35 |
# File 'lib/baseline_red_rpm/reporters/json_client.rb', line 32 def stop @thread.terminate if @thread emit_batch(@collector.retrieve) end |