Sha256: 3394e54ae0ed4f10bb5c9b072b39406b2a775902e4f6bc08e513ffcb0b579648
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
class Remnant module ClassMethods def configure(&block) configuration.instance_eval(&block) end def configuration @configuration ||= Remnant::Configuration.new.defaults! end def handler @handler ||= Statsd.new(Remnant.configuration.hostname, Remnant.configuration.port_number) end def collect @sample_counter ||= 0 extra_remnant_key = Remnant::Discover.results.delete(:extra_remnant_key) if ::Rails.env.production? || ::Rails.env.staging? || ::Rails.env.demo? # only log if above sample rate if @sample_counter > configuration.sample_rate Remnant::Discover.results.map do |remnant_key, ms| key = [ Remnant.configuration.tag, Remnant.configuration.env, extra_remnant_key, remnant_key ].compact.join('.') Remnant.handler.timing(key, ms.to_i) end @sample_counter = 0 else @sample_counter += 1 end else # always log in development mode Rails.logger.info "--------------Remnants Discovered--------------" Remnant::Discover.results.map do |remnant_key, ms| key = [ extra_remnant_key, remnant_key ].compact.join('.') Rails.logger.info "#{ms.to_i}ms\t#{key}" end Rails.logger.info "-----------------------------------------------" end # run hook if given unless Remnant.configuration.custom_hook.nil? Remnant.configuration.custom_hook.call(Remnant::Discover.results) end Remnant::Discover.results.clear end end extend ClassMethods end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
remnant-0.2.4 | lib/remnant/base.rb |