module RorVsWild
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/rorvswild.rbs module RorVsWild def self.agent: () -> RorVsWild::Agent def self.clock_milliseconds: () -> Integer end
def self.agent
Experimental RBS support (using type sampling data from the type_fusion
project).
def self.agent: () -> RorVsWild::Agent
This signature was generated using 110 samples from 1 application.
def self.agent @agent end
def self.catch_error(context = nil, &block)
def self.catch_error(context = nil, &block) agent ? agent.catch_error(context, &block) : block.call end
def self.check
def self.check api_key = RorVsWild.agent.config[:api_key] return puts "You 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
def self.clock_milliseconds
Experimental RBS support (using type sampling data from the type_fusion
project).
def self.clock_milliseconds: () -> Integer
This signature was generated using 23 samples from 1 application.
def self.clock_milliseconds Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond) end
def self.initialize_logger(destination = nil)
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
def self.logger
def self.logger @logger ||= initialize_logger end
def self.measure(code_or_name = nil, &block)
def self.measure(code_or_name = nil, &block) block ? measure_block(code_or_name, &block) : measure_code(code_or_name) end
def self.measure_block(name, &block)
def self.measure_block(name, &block) agent ? agent.measure_block(name , &block) : block.call end
def self.measure_code(code)
def self.measure_code(code) agent ? agent.measure_code(code) : eval(code) end
def self.merge_error_context(hash)
def self.merge_error_context(hash) agent.merge_error_context(hash) if agent end
def self.record_error(exception, context = nil)
def self.record_error(exception, context = nil) agent.record_error(exception, context) if agent end
def self.start(config)
def self.start(config) @logger = initialize_logger(config[:logger]) @agent = Agent.new(config) rescue Exception => ex logger.error(ex) raise end