module RorVsWild
Constants
- VERSION
Public Class Methods
agent()
click to toggle source
# File lib/rorvswild.rb, line 21 def self.agent @agent end
catch_error(context = nil, &block)
click to toggle source
# File lib/rorvswild.rb, line 51 def self.catch_error(context = nil, &block) agent ? agent.catch_error(context, &block) : block.call end
check()
click to toggle source
# File lib/rorvswild.rb, line 83 def self.check api_key = RorVsWild.agent.config[:api_key] agent.client.instance_variable_set(:@http_unauthorized, false) return puts "Your API key is missing and has to be defined in config/rorvswild.yml." if !api_key || api_key.empty? puts case response = agent.client.post("/jobs", jobs: [{sections: [], name: "RorVsWild.check", runtime: 0}]) when Net::HTTPOK then "Connection to RorVsWild works fine !" when Net::HTTPUnauthorized then "Wrong API key" else puts "Something went wrong: #{response.inspect}" end end
clock_milliseconds()
click to toggle source
# File lib/rorvswild.rb, line 79 def self.clock_milliseconds Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_millisecond) end
initialize_logger(destination = nil)
click to toggle source
# File lib/rorvswild.rb, line 67 def self.initialize_logger(destination = nil) if destination.respond_to?(:info) && destination.respond_to?(:warn) && destination.respond_to?(:error) destination elsif destination Logger.new(destination) elsif defined?(Rails) Rails.logger else Logger.new(STDOUT) end end
logger()
click to toggle source
# File lib/rorvswild.rb, line 25 def self.logger @logger ||= initialize_logger end
measure(method_or_code = nil, &block)
click to toggle source
# File lib/rorvswild.rb, line 29 def self.measure(method_or_code = nil, &block) if block measure_block(method_or_code, &block) elsif method_or_code.is_a?(Method) || method_or_code.is_a?(UnboundMethod) measure_method(method_or_code) else measure_code(method_or_code) end end
measure_block(name, &block)
click to toggle source
# File lib/rorvswild.rb, line 43 def self.measure_block(name, &block) agent ? agent.measure_block(name , &block) : block.call end
measure_code(code)
click to toggle source
# File lib/rorvswild.rb, line 39 def self.measure_code(code) agent ? agent.measure_code(code) : eval(code) end
measure_method(method)
click to toggle source
# File lib/rorvswild.rb, line 47 def self.measure_method(method) agent.measure_method(method) if agent end
merge_error_context(hash)
click to toggle source
# File lib/rorvswild.rb, line 59 def self.merge_error_context(hash) agent.merge_error_context(hash) if agent end
record_error(exception, context = nil)
click to toggle source
# File lib/rorvswild.rb, line 55 def self.record_error(exception, context = nil) agent.record_error(exception, context) if agent end
send_server_timing=(boolean)
click to toggle source
# File lib/rorvswild.rb, line 63 def self.send_server_timing=(boolean) agent.send_server_timing = boolean if agent end
start(config)
click to toggle source
# File lib/rorvswild.rb, line 13 def self.start(config) @logger = initialize_logger(config[:logger]) @agent = Agent.new(config) rescue Exception => ex logger.error(ex) raise end