unleash 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46123d78efc7bf615f2ccf84d20087a6680b7999fed0e4b4e22014b044b7d455
4
- data.tar.gz: 9992d9a6da906ab49b7ab5cfb9b8521c3f8bdd849ac76099153157debe3a989b
3
+ metadata.gz: e5eec84ff0d0a4890c3cc4f4605bc67762c5d4e434a0068e8a95cc5dbad830c3
4
+ data.tar.gz: 622ca11c209b7c214bc9e4c0114f0f2ec536c678d7faf536d8d657142c7201fc
5
5
  SHA512:
6
- metadata.gz: 49a49172df9366a14e26ae3d5486347fd9bf0cab8b154139bceb642a5f586ac2e01b617c4756c8e64a48a96d7f93605e686d98092ba86cd1db5bcb4e24142641
7
- data.tar.gz: eb53f5f237afe96847ac14cc9af19a4d517c63e874cc829c957bf729e80cdf05f5d251393d918e36ccedc1e15ad0e8933923b5561674126c518a6322ea0956ad
6
+ metadata.gz: 5ac3bd355cf79dc61be37bd9a2df183e89e95b5221914382ef767063eb831a528e48eb558556877c3f208abbb648acf9af029eb27b5c629d18f53823d77b03a0
7
+ data.tar.gz: 2f5f1af33f7e9b60016a8e3c8f6434fff6f8ddb4e0d3cd5cafa1cb03550536cd6d95caa964b2945485509a6286387a6395173fe782d178b42ea1dd67bc9c20ad
@@ -31,6 +31,7 @@ jobs:
31
31
  - jruby-9.4
32
32
  - jruby-9.3
33
33
  - jruby-9.2
34
+ - 3.3
34
35
  - 3.2
35
36
  - 3.1
36
37
  - '3.0'
@@ -41,7 +42,7 @@ jobs:
41
42
  needs:
42
43
  - lint
43
44
  steps:
44
- - uses: actions/checkout@v3
45
+ - uses: actions/checkout@v4
45
46
  - name: Set up Ruby ${{ matrix.ruby-version }}
46
47
  uses: ruby/setup-ruby@v1
47
48
  with:
data/.rubocop.yml CHANGED
@@ -127,6 +127,8 @@ Layout/BeginEndAlignment:
127
127
  Enabled: true
128
128
  Layout/EmptyLinesAroundAttributeAccessor:
129
129
  Enabled: true
130
+ Layout/FirstHashElementIndentation:
131
+ EnforcedStyle: consistent
130
132
  Layout/SpaceAroundMethodCallOperator:
131
133
  Enabled: true
132
134
  Layout/MultilineMethodCallIndentation:
data/CHANGELOG.md CHANGED
@@ -13,6 +13,15 @@ Note: These changes are not considered notable:
13
13
 
14
14
  ## [Unreleased]
15
15
 
16
+ ## [5.0.1] - 2024-03-27
17
+ ### Changed
18
+ - make user-agent headers more descriptive (#168)
19
+
20
+ ### Fixed
21
+ - make client more resilient to non-conforming responses from `unleash-edge` (#162)
22
+ - while the unleash server provides always valid responses, (at least some versions of) unleash-edge can provide an unexpected JSON response (null instead of empty array).
23
+ - fixed the handling of the response, so we do not throw exceptions in this situation.
24
+
16
25
  ## [5.0.0] - 2023-10-30
17
26
  ### Added
18
27
  - change seed for variantutils to ensure fair distribution (#160)
data/README.md CHANGED
@@ -10,6 +10,7 @@ Leverage the [Unleash Server](https://github.com/Unleash/unleash) for powerful f
10
10
 
11
11
  ## Supported Ruby Interpreters
12
12
 
13
+ * MRI 3.3
13
14
  * MRI 3.2
14
15
  * MRI 3.1
15
16
  * MRI 3.0
@@ -0,0 +1,63 @@
1
+ # example on how to extend the unleash client with opentelemetry by monkey patching it.
2
+ # to be added before initializing the client.
3
+ # in rails it could be added, for example, at:
4
+ # config/initializers/unleash.rb
5
+
6
+ require 'opentelemetry-api'
7
+ require 'unleash'
8
+
9
+ module UnleashExtensions
10
+ module OpenTelemetry
11
+ TRACER = ::OpenTelemetry.tracer_provider.tracer('Unleash-Client', Unleash::VERSION)
12
+
13
+ module Client
14
+ def initialize(*opts)
15
+ UnleashExtensions::OpenTelemetry::TRACER.in_span("#{self.class.name}##{__method__}") do |_span|
16
+ super(*opts)
17
+ end
18
+ end
19
+
20
+ def is_enabled?(feature, *args)
21
+ UnleashExtensions::OpenTelemetry::TRACER.in_span("#{self.class.name}##{__method__}") do |span|
22
+ result = super(feature, *args)
23
+
24
+ # OpenTelemetry::SemanticConventions::Trace::FEATURE_FLAG_* is not in the `opentelemetry-semantic_conventions` gem yet
25
+ span.add_attributes({
26
+ 'feature_flag.provider_name' => 'Unleash',
27
+ 'feature_flag.key' => feature,
28
+ 'feature_flag.variant' => result
29
+ })
30
+
31
+ result
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ module MetricsReporter
38
+ def post
39
+ UnleashExtensions::OpenTelemetry::TRACER.in_span("#{self.class.name}##{__method__}") do |_span|
40
+ super
41
+ end
42
+ end
43
+ end
44
+
45
+ module ToggleFetcher
46
+ def fetch
47
+ UnleashExtensions::OpenTelemetry::TRACER.in_span("#{self.class.name}##{__method__}") do |_span|
48
+ super
49
+ end
50
+ end
51
+
52
+ def save!
53
+ UnleashExtensions::OpenTelemetry::TRACER.in_span("#{self.class.name}##{__method__}") do |_span|
54
+ super
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ # MonkeyPatch here:
61
+ ::Unleash::Client.prepend UnleashExtensions::OpenTelemetry::Client
62
+ ::Unleash::MetricsReporter.prepend UnleashExtensions::OpenTelemetry::MetricsReporter
63
+ ::Unleash::ToggleFetcher.prepend UnleashExtensions::OpenTelemetry::ToggleFetcher
@@ -51,6 +51,7 @@ module Unleash
51
51
 
52
52
  def http_headers
53
53
  {
54
+ 'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
54
55
  'UNLEASH-INSTANCEID' => self.instance_id,
55
56
  'UNLEASH-APPNAME' => self.app_name,
56
57
  'Unleash-Client-Spec' => '5.0.2'
@@ -189,7 +189,7 @@ module Unleash
189
189
  end
190
190
 
191
191
  def initialize_strategies(params, segment_map)
192
- params.fetch('strategies', [])
192
+ (params.fetch('strategies', []) || [])
193
193
  .select{ |s| s.has_key?('name') && Unleash.strategies.includes?(s['name']) }
194
194
  .map do |s|
195
195
  ActivationStrategy.new(
@@ -202,7 +202,7 @@ module Unleash
202
202
  end
203
203
 
204
204
  def resolve_variants(strategy)
205
- strategy.fetch("variants", [])
205
+ (strategy.fetch("variants", []) || [])
206
206
  .select{ |variant| variant.is_a?(Hash) && variant.has_key?("name") }
207
207
  .map do |variant|
208
208
  VariantDefinition.new(
@@ -1,3 +1,3 @@
1
1
  module Unleash
2
- VERSION = "5.0.0".freeze
2
+ VERSION = "5.0.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unleash
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renato Arruda
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-30 00:00:00.000000000 Z
11
+ date: 2024-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: murmurhash3
@@ -162,6 +162,7 @@ files:
162
162
  - bin/unleash-client
163
163
  - examples/bootstrap.rb
164
164
  - examples/default-toggles.json
165
+ - examples/extending_unleash_with_opentelemetry.rb
165
166
  - examples/simple.rb
166
167
  - lib/unleash.rb
167
168
  - lib/unleash/activation_strategy.rb
@@ -200,7 +201,7 @@ homepage: https://github.com/unleash/unleash-client-ruby
200
201
  licenses:
201
202
  - Apache-2.0
202
203
  metadata: {}
203
- post_install_message:
204
+ post_install_message:
204
205
  rdoc_options: []
205
206
  require_paths:
206
207
  - lib
@@ -215,8 +216,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
216
  - !ruby/object:Gem::Version
216
217
  version: '0'
217
218
  requirements: []
218
- rubygems_version: 3.3.15
219
- signing_key:
219
+ rubygems_version: 3.3.3
220
+ signing_key:
220
221
  specification_version: 4
221
222
  summary: Unleash feature toggle client.
222
223
  test_files: []