Exception: SplitIoClient::BinarySearchLatencyTracker
- Inherits:
-
NoMethodError
- Object
- NoMethodError
- SplitIoClient::BinarySearchLatencyTracker
- Defined in:
- lib/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) ⇒ Object
Increment the internal counter for the bucket this latency falls into.
-
#add_latency_millis(millis) ⇒ 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/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/engine/metrics/binary_search_latency_tracker.rb', line 45 def latencies @latencies end |
Instance Method Details
#add_latency_micros(micros) ⇒ Object
Increment the internal counter for the bucket this latency falls into.
63 64 65 66 67 |
# File 'lib/engine/metrics/binary_search_latency_tracker.rb', line 63 def add_latency_micros(micros) index = find_bucket_index(micros) @latencies[index] += 1 @latencies end |
#add_latency_millis(millis) ⇒ Object
Increment the internal counter for the bucket this latency falls into.
55 56 57 58 59 |
# File 'lib/engine/metrics/binary_search_latency_tracker.rb', line 55 def add_latency_millis(millis) index = find_bucket_index(millis * 1000) @latencies[index] += 1 @latencies end |
#clear ⇒ Object
81 82 83 |
# File 'lib/engine/metrics/binary_search_latency_tracker.rb', line 81 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.
101 102 103 |
# File 'lib/engine/metrics/binary_search_latency_tracker.rb', line 101 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.
91 92 93 |
# File 'lib/engine/metrics/binary_search_latency_tracker.rb', line 91 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.
73 74 75 |
# File 'lib/engine/metrics/binary_search_latency_tracker.rb', line 73 def get_latencies @latencies end |
#get_latency(index) ⇒ Object
77 78 79 |
# File 'lib/engine/metrics/binary_search_latency_tracker.rb', line 77 def get_latency(index) return @latencies[index] end |