Class: Nugget::Backstop
- Inherits:
-
Object
- Object
- Nugget::Backstop
- Defined in:
- lib/nugget/backstop.rb
Class Method Summary collapse
- .backstop_requst(metric, value) ⇒ Object
- .send_metrics(name, result, response) ⇒ Object
- .send_test_result(name, result) ⇒ Object
- .send_test_timings(name, response) ⇒ Object
Class Method Details
.backstop_requst(metric, value) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/nugget/backstop.rb', line 29 def self.backstop_requst(metric, value) Nugget::Log.debug("Sending the following to backstop: #{metric}: #{value}") body = [{ :metric => metric, :value => value, :measure_time => Time.now.to_i }].to_json request = Typhoeus::Request.new( Nugget::Config.backstop_url, :method => :post, :body => body, :headers => { 'Content-Type' => 'application/json' } ) response = request.run if response.[:response_code] > 299 # hack a bad response error in here Nugget::Log.error("Error publishing #{metric} to backstop, got #{response.[:response_code]}") end end |
.send_metrics(name, result, response) ⇒ Object
4 5 6 7 |
# File 'lib/nugget/backstop.rb', line 4 def self.send_metrics(name, result, response) send_test_result(name, result) send_test_timings(name, response) end |
.send_test_result(name, result) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/nugget/backstop.rb', line 9 def self.send_test_result(name, result) if result == "FAIL" backstop_requst("#{name}.result", 1) else backstop_requst("#{name}.result", 0) end end |
.send_test_timings(name, response) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/nugget/backstop.rb', line 19 def self.send_test_timings(name, response) response.each do |key, value| if key.to_s.include?("_time") backstop_requst("#{name}.#{key}", value) end end end |