splitclient-rb 3.1.0.pre.rc6 → 3.1.0.pre.rc7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.txt +1 -0
- data/README.md +2 -0
- data/lib/engine/api/segments.rb +1 -1
- data/lib/engine/api/splits.rb +1 -1
- data/lib/engine/impressions/impressions.rb +14 -5
- data/lib/engine/parser/split_adapter.rb +1 -1
- data/lib/splitclient-rb/split_config.rb +12 -0
- data/lib/splitclient-rb/split_factory.rb +3 -0
- data/lib/splitclient-rb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 466e08e89ced1060fc54b61943291949d592de14
|
4
|
+
data.tar.gz: d3dc48c5aadb358a573cec5d7774d173edcf0673
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 929793f1ddf099968d42c1ff6397b127cf5e11791e66f702b44304374baed4b16600e5a2185941b71e8e4416999175f6530cfdd7d85dc33523dc17331c4ddd55
|
7
|
+
data.tar.gz: e992dcbac1d607b045da85132bdb913e72cd8b4d4cf98e12a002f97d3a2275488a96cb544b2497451515ffe1d63414b229b4810e1c38ad09ed2370fe92ce448a
|
data/CHANGES.txt
CHANGED
data/README.md
CHANGED
@@ -104,6 +104,8 @@ The following values can be customized:
|
|
104
104
|
|
105
105
|
**impressions_refresh_rate** : The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers in seconds
|
106
106
|
|
107
|
+
**impressions_queue_size** : The size of the impressions queue. -1 to disable impressions.
|
108
|
+
|
107
109
|
*default value* = `60`
|
108
110
|
|
109
111
|
**debug_enabled** : Enables extra logging
|
data/lib/engine/api/segments.rb
CHANGED
@@ -49,7 +49,7 @@ module SplitIoClient
|
|
49
49
|
|
50
50
|
segments << segment_content
|
51
51
|
else
|
52
|
-
@config.logger.error(
|
52
|
+
@config.logger.error("Unexpected result from API Call for Segment #{name} status #{segment.status.to_s} since #{since.to_s}")
|
53
53
|
@metrics.count(prefix + '.status.' + segment.status.to_s, 1)
|
54
54
|
end
|
55
55
|
|
data/lib/engine/api/splits.rb
CHANGED
@@ -22,7 +22,7 @@ module SplitIoClient
|
|
22
22
|
else
|
23
23
|
@metrics.count(prefix + '.status.' + splits.status.to_s, 1)
|
24
24
|
|
25
|
-
@config.logger.error('Unexpected result from API call')
|
25
|
+
@config.logger.error('Unexpected result from Splits API call')
|
26
26
|
end
|
27
27
|
|
28
28
|
latency = (Time.now - start) * 1000.0
|
@@ -18,10 +18,11 @@ module SplitIoClient
|
|
18
18
|
#
|
19
19
|
# initializes the class
|
20
20
|
#
|
21
|
-
# @param
|
22
|
-
def initialize(
|
23
|
-
@
|
24
|
-
@
|
21
|
+
# @param config [SplitConfig] the config object
|
22
|
+
def initialize(config)
|
23
|
+
@config = config
|
24
|
+
@queue = SizedQueue.new(config.impressions_queue_size <= 0? 1 : config.impressions_queue_size)
|
25
|
+
@max_number_of_keys = config.impressions_queue_size
|
25
26
|
end
|
26
27
|
|
27
28
|
#
|
@@ -34,8 +35,16 @@ module SplitIoClient
|
|
34
35
|
#
|
35
36
|
# @return void
|
36
37
|
def log(id, feature, treatment, time)
|
38
|
+
return if @max_number_of_keys <= 0 # shortcut to desable impressions
|
37
39
|
impressions = KeyImpressions.new(id, treatment, time)
|
38
|
-
|
40
|
+
begin
|
41
|
+
@queue.push( {feature: feature, impressions: impressions} , true ) # don't wait if queue is full
|
42
|
+
rescue ThreadError
|
43
|
+
@random_sampler ||= Random.new
|
44
|
+
if @random_sampler.rand(1..1000) <= 2 # log only 0.2 % of the time.
|
45
|
+
@config.logger.warn("Dropping impressions. Current size is #{@max_number_of_keys}. Consider increasing impressions_queue_size")
|
46
|
+
end
|
47
|
+
end
|
39
48
|
end
|
40
49
|
|
41
50
|
#
|
@@ -42,7 +42,7 @@ module SplitIoClient
|
|
42
42
|
def initialize(api_key, config, splits_repository, segments_repository, sdk_blocker)
|
43
43
|
@api_key = api_key
|
44
44
|
@config = config
|
45
|
-
@impressions = Impressions.new(
|
45
|
+
@impressions = Impressions.new(@config)
|
46
46
|
@metrics = Metrics.new(100)
|
47
47
|
|
48
48
|
@splits_repository = splits_repository
|
@@ -21,6 +21,7 @@ module SplitIoClient
|
|
21
21
|
# @option opts [Int] :impressions_refresh_rate
|
22
22
|
# @option opts [Object] :logger a logger to user for messages from the client. Defaults to stdout
|
23
23
|
# @option opts [Boolean] :debug_enabled (false) The value for the debug flag
|
24
|
+
# @option opts [Int] :impressions_queue_size how big the impressions queue is before dropping impressions. -1 to disable it.
|
24
25
|
#
|
25
26
|
# @return [type] SplitConfig with configuration options
|
26
27
|
def initialize(opts = {})
|
@@ -35,6 +36,7 @@ module SplitIoClient
|
|
35
36
|
@segments_refresh_rate = opts[:segments_refresh_rate] || SplitConfig.default_segments_refresh_rate
|
36
37
|
@metrics_refresh_rate = opts[:metrics_refresh_rate] || SplitConfig.default_metrics_refresh_rate
|
37
38
|
@impressions_refresh_rate = opts[:impressions_refresh_rate] || SplitConfig.default_impressions_refresh_rate
|
39
|
+
@impressions_queue_size = opts[:impressions_queue_size] || SplitConfig.default_impressions_queue_size
|
38
40
|
@logger = opts[:logger] || SplitConfig.default_logger
|
39
41
|
@debug_enabled = opts[:debug_enabled] || SplitConfig.default_debug
|
40
42
|
@transport_debug_enabled = opts[:transport_debug_enabled] || SplitConfig.default_debug
|
@@ -113,6 +115,12 @@ module SplitIoClient
|
|
113
115
|
attr_reader :metrics_refresh_rate
|
114
116
|
attr_reader :impressions_refresh_rate
|
115
117
|
|
118
|
+
#
|
119
|
+
# Wow big the impressions queue is before dropping impressions. -1 to disable it.
|
120
|
+
#
|
121
|
+
# @return [Integer]
|
122
|
+
attr_reader :impressions_queue_size
|
123
|
+
|
116
124
|
attr_reader :redis_url
|
117
125
|
|
118
126
|
#
|
@@ -185,6 +193,10 @@ module SplitIoClient
|
|
185
193
|
60
|
186
194
|
end
|
187
195
|
|
196
|
+
def self.default_impressions_queue_size
|
197
|
+
5000
|
198
|
+
end
|
199
|
+
|
188
200
|
#
|
189
201
|
# The default logger object
|
190
202
|
#
|
@@ -200,6 +200,9 @@ module SplitIoClient
|
|
200
200
|
begin
|
201
201
|
@adapter.impressions.log(matching_key, split_name, result, (Time.now.to_f * 1000.0))
|
202
202
|
latency = (Time.now - start) * 1000.0
|
203
|
+
|
204
|
+
# Measure
|
205
|
+
@adapter.metrics.time("sdk.get_treatment", latency)
|
203
206
|
rescue StandardError => error
|
204
207
|
@config.log_found_exception(__method__.to_s, error)
|
205
208
|
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: 3.1.0.pre.
|
4
|
+
version: 3.1.0.pre.rc7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Split Software
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|