splitclient-rb 6.4.0 → 6.4.1.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86c89d8f5625455516d031b21565ae8c24c9a790b2cab13340aaf7f549cddb91
4
- data.tar.gz: f055fb7c29be50dc802cf009473f52179c122eb9a4ff5e3fe71a4b5d9d4f454a
3
+ metadata.gz: f474b8941f870d494de1e1c5314b2b880c12672cf9d46b17ceb902e99e85050a
4
+ data.tar.gz: 27e00346829c95698a5e19acd95d392c9805a857cb5882ef0a94ff4011ea41d5
5
5
  SHA512:
6
- metadata.gz: b89e8fb171fbb6ac3b6d4ab96f6a10196bad8962f3cec4913dad5e137ad54d4495434cf48bf3010f3ce1fab34fb36d8a7b03e5515a8a2252af5d8e78d6477e93
7
- data.tar.gz: 65df4efc489b8fd6124e0e5018da58a87823e060fd2f6f94fc32a91ea94105f7b8c3d847ba132862f2bf874d092a91ed75816938a38eb38dccb8b5db0af382f0
6
+ metadata.gz: 9463b792568144eeec07f22bd3550ad5e3b626de832752694e67c82792f884c3627e0f1b1774a3cff6168c860dbf0b248873df6848db39f1b43f487600361956
7
+ data.tar.gz: 8e2431113432f21f485ad67009c538bdfaba2902828e872099b2cf89e739bbbfae4c8114c20e49fa2e77357ed7cee9d0e524b341ca1d8667ba0607d6a5fd47f7
data/CHANGES.txt CHANGED
@@ -1,7 +1,5 @@
1
- 6.4.0 (Jul 05, 2019)
2
- - Added properties to track method.
3
-
4
1
  6.3.0 (Apr 30, 2019)
2
+
5
3
  - Added Dynamic Configurations support through two new methods that mimick the regular ones, changing the type of what is returned.
6
4
  - get_treatment_with_config: Same as get_treatment but returning the treatment with it's config.
7
5
  - get_treatments_with_config: Same as get_treatments, but instead of a map of string it returns a map of treatments with config.
data/NEWS CHANGED
@@ -1,6 +1,3 @@
1
- 6.4.0 (Jul 05, 2019)
2
- - Added properties to track method.
3
-
4
1
  6.3.0 (Apr 30, 2019)
5
2
 
6
3
  - Added Dynamic Configurations support through two new methods that mimick the regular ones, changing the type of what is returned.
@@ -3,6 +3,8 @@ module SplitIoClient
3
3
  module Repositories
4
4
  module Metrics
5
5
  class MemoryRepository
6
+ OPERATIONS = %w(sdk.get_treatment sdk.get_treatments sdk.get_treatment_with_config sdk.get_treatments_with_config)
7
+
6
8
  def initialize(_ = nil, adapter)
7
9
  @counts = []
8
10
  @latencies = []
@@ -23,13 +25,25 @@ module SplitIoClient
23
25
  def add_latency(operation, time_in_ms, binary_search)
24
26
  operation_hash = @latencies.find { |l| l[:operation] == operation }
25
27
  if operation_hash.nil?
26
- latencies_for_op = (operation == 'sdk.get_treatment') ? binary_search.add_latency_millis(time_in_ms) : [time_in_ms]
28
+ latencies_for_op = (OPERATIONS.include?(operation)) ? build_latencies_for_op(operation, binary_search.add_latency_millis(time_in_ms, true)) : [time_in_ms]
27
29
  @latencies << { operation: operation, latencies: latencies_for_op }
28
30
  else
29
- latencies_for_op = (operation == 'sdk.get_treatment') ? binary_search.add_latency_millis(time_in_ms) : operation_hash[:latencies].push(time_in_ms)
31
+ (OPERATIONS.include?(operation)) ? increase_latencies_for_op(operation_hash[:latencies], binary_search.add_latency_millis(time_in_ms, true)) : operation_hash[:latencies].push(time_in_ms)
30
32
  end
31
33
  end
32
34
 
35
+ def build_latencies_for_op(operation, index)
36
+ latencies_array = Array.new(BinarySearchLatencyTracker::BUCKETS.length, 0)
37
+
38
+ latencies_array[index] = 1
39
+
40
+ latencies_array
41
+ end
42
+
43
+ def increase_latencies_for_op(operation_latencies_array, index)
44
+ operation_latencies_array[index] += 1
45
+ end
46
+
33
47
  def add_gauge(gauge, value)
34
48
  gauge_hash = @gauges.find { |g| g[:name] == gauge }
35
49
  if gauge_hash.nil?
@@ -17,12 +17,7 @@ module SplitIoClient
17
17
  def add_latency(operation, time_in_ms, binary_search)
18
18
  prefixed_name = impressions_metrics_key("latency.#{operation}")
19
19
 
20
- if operation == 'sdk.get_treatment'
21
- @adapter.inc("#{prefixed_name}.#{binary_search.add_latency_millis(time_in_ms, true)}")
22
- return
23
- end
24
-
25
- @adapter.append_to_string(prefixed_name, "#{time_in_ms},")
20
+ @adapter.inc("#{prefixed_name}.bucket.#{binary_search.add_latency_millis(time_in_ms, true)}")
26
21
  end
27
22
 
28
23
  def add_gauge(gauge, value)
@@ -40,30 +35,33 @@ module SplitIoClient
40
35
  end
41
36
 
42
37
  def latencies
43
- collected_latencies = {}
44
- latencies_array = Array.new(BinarySearchLatencyTracker::BUCKETS.length, 0)
45
38
  keys = @adapter.find_strings_by_prefix(impressions_metrics_key('latency'))
46
-
47
39
  return [] if keys.empty?
48
40
 
49
41
  found_latencies = @adapter.multiple_strings(keys).map do |name, data|
50
42
  [name.gsub(impressions_metrics_key('latency.'), ''), data]
51
43
  end.to_h
52
44
 
45
+ collected_latencies = {}
46
+
53
47
  found_latencies.each do |key, value|
54
- if key.start_with?('sdk.get_treatment')
55
- index = key.gsub('sdk.get_treatment.', '').to_i
56
- latencies_array[index] = value.to_i
48
+ operation, bucket = key.split('.bucket.')
49
+ collected_latencies[operation] = {} unless collected_latencies[operation]
50
+ collected_latencies[operation].merge!({bucket => value})
51
+ end
57
52
 
58
- next
53
+ latencies = {}
54
+
55
+ collected_latencies.keys.each do |operation|
56
+ latencies_array = Array.new(BinarySearchLatencyTracker::BUCKETS.length, 0)
57
+ collected_latencies[operation].each do |bucket, value|
58
+ latencies_array[bucket.to_i] = value.to_i
59
59
  end
60
60
 
61
- collected_latencies[key] = value.split(',').map(&:to_f)
61
+ latencies[operation] = latencies_array
62
62
  end
63
63
 
64
- collected_latencies['sdk.get_treatment'] = latencies_array unless latencies_array.reduce(:+) == 0
65
-
66
- collected_latencies
64
+ latencies
67
65
  end
68
66
 
69
67
  def gauges
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '6.4.0'
2
+ VERSION = '6.4.1.pre.rc1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splitclient-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.4.0
4
+ version: 6.4.1.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Split Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-05 00:00:00.000000000 Z
11
+ date: 2019-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: allocation_stats
@@ -403,12 +403,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
403
403
  version: '0'
404
404
  required_rubygems_version: !ruby/object:Gem::Requirement
405
405
  requirements:
406
- - - ">="
406
+ - - ">"
407
407
  - !ruby/object:Gem::Version
408
- version: '0'
408
+ version: 1.3.1
409
409
  requirements: []
410
- rubyforge_project:
411
- rubygems_version: 2.7.10
410
+ rubygems_version: 3.0.3
412
411
  signing_key:
413
412
  specification_version: 4
414
413
  summary: Ruby client for split SDK.