Sha256: 9dc4ab23168e1f02bdfae92c498eed6a0c0eb4078e7807f846cb5f79086c20ce

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 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
      extra_remnant_key = Remnant::Discover.results.delete(:extra_remnant_key)

      if ::Rails.env.production?
        # send on
        Remnant::Discover.results.map do |remnant_key, ms|
          key = [
                 Remnant.configuration.tag,
                 Remnant.configuration.env,
                 extra_remnant_key,
                 remnant_key
                ].compact.join('.')

          Remannt.handler.timing(key, ms.to_i)
        end
      else
        # log it
        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

      Remnant::Discover.results.clear
    end
  end
  extend ClassMethods
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
remnant-0.1.1 lib/remnant/base.rb
remnant-0.1.0 lib/remnant/base.rb