unleash 6.2.0 → 6.2.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: 4370c29490f14c2ece25f21614db57de48b748cea8215da748d7635bd9d27bbf
4
- data.tar.gz: eb2cdff78e994647a70fca33497d144f0e4366d75612670077c1689d6d37dcac
3
+ metadata.gz: 32ddaecfae8bb5a049359c13075e734a22047d2f125e14803ee37d8e2934f915
4
+ data.tar.gz: 9de21ac17035d20000e559fb14faec6c9bfa00af33d5b8d4d4b8300f45a110a3
5
5
  SHA512:
6
- metadata.gz: 63a24dbca52e439f57c24a4c1f6894f172386ee898704e4570877c59b3a2b542e98eff9463b75a01fb54f5aa37ecab43e98b12119dbe03cf87be4e0e6792cae6
7
- data.tar.gz: caa9b7b541d60b3ab99f5cbf270adac69211fe4424e80202ad12c4882f49295829a3aeb267cd7400fee5dbe393fcd355cc8db7fb9ebf419ee04a31dc1c0840ba
6
+ metadata.gz: '014049ad81c82301dc19cd6b5ad5654447844bf5a1421b0b45d3fe663ca0d7d6b5747db1a97478ebdcf0a617eeb381d08686d5c136986ee4f6d9e513c3f527e3'
7
+ data.tar.gz: 700d96af0897156beff38e9d7fc844061efce25aee11fa317a8834350909b499df7aaa8f2a775f49e8d7e69778e5241cd4f4b6d07e7ad3de7e5a73fdac2e5218
data/CHANGELOG.md CHANGED
@@ -13,6 +13,10 @@ Note: These changes are not considered notable:
13
13
 
14
14
  ## [Unreleased]
15
15
 
16
+ ## [6.2.1] - 2025-04-14
17
+ ### Fixed
18
+ - metrics sending no longer fails after 10 minutes
19
+
16
20
  ## [6.2.0] - 2024-02-28
17
21
  ### Added
18
22
  - unleash-interval header (#236)
@@ -15,7 +15,8 @@ module Unleash
15
15
  return configuration.data unless self.configuration.data.nil?
16
16
  return configuration.block.call if self.configuration.block.is_a?(Proc)
17
17
  return Provider::FromFile.read(configuration.file_path) unless self.configuration.file_path.nil?
18
- return Provider::FromUrl.read(configuration.url, configuration.url_headers) unless self.configuration.url.nil?
18
+
19
+ Provider::FromUrl.read(configuration.url, configuration.url_headers) unless self.configuration.url.nil?
19
20
  end
20
21
  end
21
22
  end
@@ -7,8 +7,8 @@ module Unleash
7
7
  def initialize(params = {})
8
8
  raise ArgumentError, "Unleash::Context must be initialized with a hash." unless params.is_a?(Hash)
9
9
 
10
- self.app_name = value_for("appName", params, Unleash&.configuration&.app_name)
11
- self.environment = value_for("environment", params, Unleash&.configuration&.environment || "default")
10
+ self.app_name = value_for("appName", params, Unleash.configuration&.app_name)
11
+ self.environment = value_for("environment", params, Unleash.configuration&.environment || "default")
12
12
  self.user_id = value_for("userId", params)&.to_s
13
13
  self.session_id = value_for("sessionId", params)
14
14
  self.remote_address = value_for("remoteAddress", params)
@@ -14,8 +14,24 @@ module Unleash
14
14
  end
15
15
 
16
16
  def generate_report
17
- metrics = Unleash&.engine&.get_metrics()
17
+ metrics = Unleash.engine&.get_metrics
18
+ return nil if metrics.nil?
18
19
 
20
+ generate_report_from_bucket metrics
21
+ end
22
+
23
+ def post
24
+ Unleash.logger.debug "post() Report"
25
+
26
+ report = build_report
27
+ return unless report
28
+
29
+ send_report(report)
30
+ end
31
+
32
+ private
33
+
34
+ def generate_report_from_bucket(bucket)
19
35
  {
20
36
  'platformName': RUBY_ENGINE,
21
37
  'platformVersion': RUBY_VERSION,
@@ -24,20 +40,23 @@ module Unleash
24
40
  'appName': Unleash.configuration.app_name,
25
41
  'instanceId': Unleash.configuration.instance_id,
26
42
  'connectionId': Unleash.configuration.connection_id,
27
- 'bucket': metrics || {}
43
+ 'bucket': bucket
28
44
  }
29
45
  end
30
46
 
31
- def post
32
- Unleash.logger.debug "post() Report"
33
-
34
- report = self.generate_report
47
+ def build_report
48
+ report = generate_report
49
+ return nil if report.nil? && Time.now - self.last_time < LONGEST_WITHOUT_A_REPORT
35
50
 
36
- if report[:bucket].empty? && (Time.now - self.last_time < LONGEST_WITHOUT_A_REPORT) # and last time is less then 10 minutes...
37
- Unleash.logger.debug "Report not posted to server, as it would have been empty. (and has been empty for up to 10 min)"
38
- return
39
- end
51
+ report || generate_report_from_bucket({
52
+ 'start': self.last_time.utc.iso8601,
53
+ 'stop': Time.now.utc.iso8601,
54
+ 'toggles': {}
55
+ })
56
+ end
40
57
 
58
+ def send_report(report)
59
+ self.last_time = Time.now
41
60
  headers = (Unleash.configuration.http_headers || {}).dup
42
61
  headers.merge!({ 'UNLEASH-INTERVAL' => Unleash.configuration.metrics_interval.to_s })
43
62
  response = Unleash::Util::Http.post(Unleash.configuration.client_metrics_uri, report.to_json, headers)
@@ -1,3 +1,3 @@
1
1
  module Unleash
2
- VERSION = "6.2.0".freeze
2
+ VERSION = "6.2.1".freeze
3
3
  end
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  # rubocop:disable Gemspec/RubyVersionGlobalsUsage, Style/IfUnlessModifier
38
38
  if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('3.0')
39
- spec.add_development_dependency "rubocop", "~> 1.51.0"
39
+ spec.add_development_dependency "rubocop", "~> 1.75"
40
40
  end
41
41
  # rubocop:enable Gemspec/RubyVersionGlobalsUsage, Style/IfUnlessModifier
42
42
 
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: 6.2.0
4
+ version: 6.2.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: 2025-03-03 00:00:00.000000000 Z
11
+ date: 2025-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yggdrasil-engine
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.51.0
131
+ version: '1.75'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.51.0
138
+ version: '1.75'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: simplecov
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -216,7 +216,7 @@ homepage: https://github.com/unleash/unleash-client-ruby
216
216
  licenses:
217
217
  - Apache-2.0
218
218
  metadata: {}
219
- post_install_message:
219
+ post_install_message:
220
220
  rdoc_options: []
221
221
  require_paths:
222
222
  - lib
@@ -231,8 +231,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
231
  - !ruby/object:Gem::Version
232
232
  version: '0'
233
233
  requirements: []
234
- rubygems_version: 3.5.22
235
- signing_key:
234
+ rubygems_version: 3.5.6
235
+ signing_key:
236
236
  specification_version: 4
237
237
  summary: Unleash feature toggle client.
238
238
  test_files: []