Sha256: 0940943848c853c09472cc8259a6303bab8ab67227b55b30c1f0a200a8c2c028

Contents?: true

Size: 1.13 KB

Versions: 36

Compression:

Stored size: 1.13 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 < Provider
      # @param logger [Logger,nil]
      def initialize(logger=nil) # rubocop:disable Lint/MissingSuper
        @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

36 entries across 36 versions & 1 rubygems

Version Path
deimos-ruby-1.24.2 lib/deimos/metrics/mock.rb
deimos-ruby-1.24.1 lib/deimos/metrics/mock.rb
deimos-ruby-1.24.0 lib/deimos/metrics/mock.rb
deimos-ruby-1.23.3 lib/deimos/metrics/mock.rb
deimos-ruby-1.23.2 lib/deimos/metrics/mock.rb
deimos-ruby-1.23.1.pre.beta6 lib/deimos/metrics/mock.rb
deimos-ruby-1.23.1.pre.beta5 lib/deimos/metrics/mock.rb
deimos-ruby-1.23.1.pre.beta4 lib/deimos/metrics/mock.rb
deimos-ruby-1.23.1.pre.beta3 lib/deimos/metrics/mock.rb
deimos-ruby-1.23.1.pre.beta2 lib/deimos/metrics/mock.rb
deimos-ruby-1.23.1.pre.beta1 lib/deimos/metrics/mock.rb
deimos-ruby-1.23.0 lib/deimos/metrics/mock.rb
deimos-ruby-1.22.5 lib/deimos/metrics/mock.rb
deimos-ruby-1.22.4 lib/deimos/metrics/mock.rb
deimos-ruby-1.22.3 lib/deimos/metrics/mock.rb
deimos-ruby-1.22.2 lib/deimos/metrics/mock.rb
deimos-ruby-1.22.1 lib/deimos/metrics/mock.rb
deimos-ruby-1.22 lib/deimos/metrics/mock.rb
deimos-ruby-1.20.1 lib/deimos/metrics/mock.rb
deimos-ruby-1.20.0 lib/deimos/metrics/mock.rb