Sha256: ae5995027b8e8421e1b8aa41c1253f9b40a3db979ad3e515ab1fb9954f113a46

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

require "harness/version"

require 'thread'

require 'redis'
require 'redis/namespace'

require 'active_support/notifications'
require 'active_support/core_ext/string'
require 'active_support/core_ext/hash/keys'
require 'active_support/core_ext/numeric'
require 'active_support/core_ext/integer'

module Harness
  class LoggingError < RuntimeError ; end
  class NoCounter < RuntimeError ; end

  class Config
    attr_reader :adapter, :queue, :namespace

    def adapter=(val)
      if val.is_a? Symbol
        @adapter = "Harness::#{val.to_s.camelize}Adapter".constantize
      else
        @adapter = val
      end
    end

    def queue=(val)
      if val.is_a? Symbol
        @queue= "Harness::#{val.to_s.camelize}Queue".constantize
      else
        @queue= val
      end
    end

    def method_missing(name, *args, &block)
      begin
        "Harness::#{name.to_s.camelize}Adapter".constantize.config
      rescue NameError
        super
      end
    end
  end

  def self.config
    @config ||= Config.new
  end

  def self.log(measurement)
    config.queue.push measurement
  end

  def self.logger
    @logger
  end

  def self.logger=(logger)
    @logger = logger
  end

  def self.redis=(redis)
    @redis = redis
  end

  def self.redis
    @redis
  end

  def self.reset_counters!
    redis.smembers('counters').each do |counter|
      redis.set counter, 0
      redis.del "meters/#{counter}"
    end
  end
end

require 'harness/measurement'
require 'harness/counter'
require 'harness/gauge'
require 'harness/meter'

require 'harness/instrumentation'

require 'harness/job'

require 'harness/queues/syncronous_queue'

require 'harness/adapters/librato_adapter'
require 'harness/adapters/memory_adapter'
require 'harness/adapters/null_adapter'

require 'harness/integration/action_controller'
require 'harness/integration/action_view'
require 'harness/integration/action_mailer'
require 'harness/integration/active_support'

require 'harness/railtie' if defined?(Rails)

require 'logger'

Harness.logger = Logger.new $stdout

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
harness-0.2.1 lib/harness.rb