Sha256: cb520e132adfedc80eb8b6f1b7a4bdc384815022cbde7bf81e7e36fac2489355

Contents?: true

Size: 1.06 KB

Versions: 88

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require 'deimos/metrics/provider'

module Deimos
  module Metrics
    # A mock Metrics wrapper which just logs the metrics
    class Mock
      # :nodoc:
      def initialize(logger=nil)
        @logger = logger || Logger.new(STDOUT)
        @logger.info('MockMetricsProvider initialized')
      end

      # :nodoc:
      def increment(metric_name, options={})
        @logger.info("MockMetricsProvider.increment: #{metric_name}, #{options}")
      end

      # :nodoc:
      def gauge(metric_name, count, options={})
        @logger.info("MockMetricsProvider.gauge: #{metric_name}, #{count}, #{options}")
      end

      # :nodoc:
      def histogram(metric_name, count, options={})
        @logger.info("MockMetricsProvider.histogram: #{metric_name}, #{count}, #{options}")
      end

      # :nodoc:
      def time(metric_name, options={})
        start_time = Time.now
        yield
        total_time = (Time.now - start_time).to_i
        @logger.info("MockMetricsProvider.time: #{metric_name}, #{total_time}, #{options}")
      end
    end
  end
end

Version data entries

88 entries across 88 versions & 2 rubygems

Version Path
deimos-ruby-1.8.7 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.6 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.5 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.4 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.3 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.2 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.2.pre.beta2 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.2.pre.beta1 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.1.pre.beta9 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.1.pre.beta8 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.1.pre.beta7 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.1.pre.beta6 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.1.pre.beta5 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.1.pre.beta4 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.1.pre.beta3 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.1.pre.beta2 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.1.pre.beta1 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.0.pre.beta2 lib/deimos/metrics/mock.rb
deimos-ruby-1.8.0.pre.beta1 lib/deimos/metrics/mock.rb
deimos-ruby-1.7.0.pre.beta1 lib/deimos/metrics/mock.rb