Exception: SplitIoClient::Metrics

Inherits:
NoMethodError
  • Object
show all
Defined in:
lib/splitclient-rb/engine/metrics/metrics.rb

Overview

class to handle cached metrics

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue_size, repository) ⇒ Metrics

Returns a new instance of Metrics.



35
36
37
38
39
# File 'lib/splitclient-rb/engine/metrics/metrics.rb', line 35

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

Instance Attribute Details

#countsobject

cached counts

Returns:

  • (object)

    array of counts



21
22
23
# File 'lib/splitclient-rb/engine/metrics/metrics.rb', line 21

def counts
  @counts
end

#gaugesobject

cached gauges

Returns:

  • (object)

    array of gauges



27
28
29
# File 'lib/splitclient-rb/engine/metrics/metrics.rb', line 27

def gauges
  @gauges
end

#latenciesobject

cached latencies

Returns:

  • (object)

    array of latencies



15
16
17
# File 'lib/splitclient-rb/engine/metrics/metrics.rb', line 15

def latencies
  @latencies
end

#queue_sizeint

quese size for cached arrays

Returns:

  • (int)

    queue size



33
34
35
# File 'lib/splitclient-rb/engine/metrics/metrics.rb', line 33

def queue_size
  @queue_size
end

Instance Method Details

#count(counter, delta) ⇒ Object

creates a new entry in the array for cached counts

Parameters:

  • counter (string)

    name of the counter

Returns:

  • void



48
49
50
51
52
# File 'lib/splitclient-rb/engine/metrics/metrics.rb', line 48

def count(counter, delta)
  return if (delta <= 0) || counter.nil? || counter.strip.empty?

  @repository.add_count(counter, delta)
end

#gauge(gauge, value) ⇒ Object

creates a new entry in the array for cached gauges

Parameters:

  • gauge (string)

    name of the gauge

Returns:

  • void



74
75
76
77
78
# File 'lib/splitclient-rb/engine/metrics/metrics.rb', line 74

def gauge(gauge, value)
  return if gauge.nil? || gauge.empty?

  @repository.add_gauge(gauge, value)
end

#time(operation, time_in_ms) ⇒ Object

creates a new entry in the array for cached time metrics

Parameters:

  • operation (string)

    name of the operation

Returns:

  • void



61
62
63
64
65
# File 'lib/splitclient-rb/engine/metrics/metrics.rb', line 61

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