Sha256: 55a0526ba367c59b2ef5e3ff19020d941de7920101943a1bd506f88f08451556

Contents?: true

Size: 1.74 KB

Versions: 65

Compression:

Stored size: 1.74 KB

Contents

module SplitIoClient

  #
  # class to handle cached metrics
  #
  class Metrics < NoMethodError

    @counter
    @delta

    #
    # cached latencies
    #
    # @return [object] array of latencies
    attr_accessor :latencies

    #
    # cached counts
    #
    # @return [object] array of counts
    attr_accessor :counts

    #
    # cached gauges
    #
    # @return [object] array of gauges
    attr_accessor :gauges

    #
    # quese size for cached arrays
    #
    # @return [int] queue size
    attr_accessor :queue_size

    def initialize(queue_size, config, repository)
      @queue_size = queue_size
      @binary_search = SplitIoClient::BinarySearchLatencyTracker.new

      @config = config

      @repository = repository
    end

    #
    # creates a new entry in the array for cached counts
    #
    # @param counter [string] name of the counter
    # @delta [int] value of the counter
    #
    # @return void
    def count(counter, delta)
      return if (delta <= 0) || counter.nil? || counter.strip.empty?

      @repository.add_count(counter, delta)
    end

    #
    # creates a new entry in the array for cached time metrics
    #
    # @param operation [string] name of the operation
    # @time_in_ms [number] time in miliseconds
    #
    # @return void
    def time(operation, time_in_ms)
      return if operation.nil? || operation.empty? || time_in_ms < 0

      @repository.add_latency(operation, time_in_ms, @binary_search)
    end

    #
    # creates a new entry in the array for cached gauges
    #
    # @param gauge [string] name of the gauge
    # @value [number] value of the gauge
    #
    # @return void
    def gauge(gauge, value)
      return if gauge.nil? || gauge.empty?

      @repository.add_gauge(gauge, value)
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
splitclient-rb-5.1.0-java lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.1.0 lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.1.0.pre.rc1-java lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.1.0.pre.rc1 lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.3-java lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.3 lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.3.pre.rc1-java lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.3.pre.rc1 lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.2-java lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.2 lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.2.pre.rc1-java lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.2.pre.rc1 lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.1-java lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.1 lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.1.pre.rc1-java lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.1.pre.rc1 lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.0-java lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.0 lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.0.pre.rc1-java lib/splitclient-rb/engine/metrics/metrics.rb
splitclient-rb-5.0.0.pre.rc1 lib/splitclient-rb/engine/metrics/metrics.rb