Exception: SplitIoClient::BinarySearchLatencyTracker
- Inherits:
-
NoMethodError
- Object
- NoMethodError
- SplitIoClient::BinarySearchLatencyTracker
- Defined in:
- lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb
Overview
Tracks latencies pero bucket of time.
Each bucket represent a latency greater than the one before
and each number within each bucket is a number of calls in the range.
(1) 1.00
(2) 1.50
(3) 2.25
(4) 3.38
(5) 5.06
(6) 7.59
(7) 11.39
(8) 17.09
(9) 25.63
(10) 38.44
(11) 57.67
(12) 86.50
(13) 129.75
(14) 194.62
(15) 291.93
(16) 437.89
(17) 656.84
(18) 985.26
(19) 1,477.89
(20) 2,216.84
(21) 3,325.26
(22) 4,987.89
(23) 7,481.83
Created by fvitale on 2/17/16 based on java implementation by patricioe.
Constant Summary collapse
- BUCKETS =
[ 1000, 1500, 2250, 3375, 5063, 7594, 11391, 17086, 25629, 38443, 57665, 86498, 129746, 194620, 291929, 437894, 656841, 985261, 1477892, 2216838, 3325257, 4987885, 7481828 ].freeze
- MAX_LATENCY =
7481828
Instance Attribute Summary collapse
-
#latencies ⇒ Object
Returns the value of attribute latencies.
Instance Method Summary collapse
-
#add_latency_micros(micros, return_index = false) ⇒ Object
Increment the internal counter for the bucket this latency falls into.
-
#add_latency_millis(millis, return_index = false) ⇒ Object
Increment the internal counter for the bucket this latency falls into.
- #clear ⇒ Object
-
#get_bucket_for_latency_micros(latency) ⇒ Object
Returns the counts in the bucket this latency falls into.
-
#get_bucket_for_latency_millis(latency) ⇒ Object
Returns the counts in the bucket this latency falls into.
-
#get_latencies ⇒ Object
Returns the list of latencies buckets as an array.
- #get_latency(index) ⇒ Object
-
#initialize ⇒ BinarySearchLatencyTracker
constructor
A new instance of BinarySearchLatencyTracker.
Constructor Details
#initialize ⇒ BinarySearchLatencyTracker
Returns a new instance of BinarySearchLatencyTracker.
47 48 49 |
# File 'lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb', line 47 def initialize @latencies = Array.new(BUCKETS.length, 0) end |
Instance Attribute Details
#latencies ⇒ Object
Returns the value of attribute latencies.
45 46 47 |
# File 'lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb', line 45 def latencies @latencies end |
Instance Method Details
#add_latency_micros(micros, return_index = false) ⇒ Object
Increment the internal counter for the bucket this latency falls into.
66 67 68 69 70 71 72 73 |
# File 'lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb', line 66 def add_latency_micros(micros, return_index = false) index = find_bucket_index(micros) return index if return_index @latencies[index] += 1 @latencies end |
#add_latency_millis(millis, return_index = false) ⇒ Object
Increment the internal counter for the bucket this latency falls into.
55 56 57 58 59 60 61 62 |
# File 'lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb', line 55 def add_latency_millis(millis, return_index = false) index = find_bucket_index(millis * 1000) return index if return_index @latencies[index] += 1 @latencies end |
#clear ⇒ Object
87 88 89 |
# File 'lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb', line 87 def clear @latencies = Array.new(BUCKETS.length, 0) end |
#get_bucket_for_latency_micros(latency) ⇒ Object
Returns the counts in the bucket this latency falls into. The latencies will not be updated.
107 108 109 |
# File 'lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb', line 107 def get_bucket_for_latency_micros(latency) return @latencies[find_bucket_index(latency)] end |
#get_bucket_for_latency_millis(latency) ⇒ Object
Returns the counts in the bucket this latency falls into. The latencies will not be updated.
97 98 99 |
# File 'lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb', line 97 def get_bucket_for_latency_millis(latency) return @latencies[find_bucket_index(latency * 1000)] end |
#get_latencies ⇒ Object
Returns the list of latencies buckets as an array.
79 80 81 |
# File 'lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb', line 79 def get_latencies @latencies end |
#get_latency(index) ⇒ Object
83 84 85 |
# File 'lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb', line 83 def get_latency(index) return @latencies[index] end |