karafka-core 2.2.0 → 2.2.1

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: d37a3eb440f0d9b3dd0c4d12c9adf68ad6a1863c934c240e0c5a78dca0ca77b5
4
- data.tar.gz: 6a20ec79c112500bf3df39c565cd5609ee6d632515c17230fd5ed0a5f1678697
3
+ metadata.gz: c2f5012295cee5675f7217bb18edc47755020845d882457151ce6e7cd92cff51
4
+ data.tar.gz: 18f2697a2e4a85ed328f8fac9b029d0085ca5d699fc74c154eaf83f8df326d6c
5
5
  SHA512:
6
- metadata.gz: 173bf9d5d86be0c159b9351930b97e36a2bc897be3ad14a1f6ca3532ef2bc393d9b554f4825e322a77f67718bdb6b8d15e08c4cc810e89db0e1b104454935543
7
- data.tar.gz: ba1bc96234bf57660dd821b9f0ecb3f7d8dd6bdc9210f2c0b2e5dfafb9ad7b22ebf7578608eb92f0f8159f45ad9f2f675b8ed579c5eb2b93bacbe27def07bb5d
6
+ metadata.gz: a5c61fece07c11cb61f46319a39530870f501991d781df5ac8697775d032ed6f6bc890a47e20709dd53086a758a6d4a8b404a6871b8b62dbbb8503b735c8b3a8
7
+ data.tar.gz: 9b602af1b041ac9b879a8df26ceb84b548aeb79f803dd9c59eff9e10762b6b6001ae29b1cba1ea4b7b63703f6a8bd65bc036109c611668401f59762102127a77
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1 @@
1
- �(��
2
- Z�)H���q Ӏ�E��+%S�~�
3
- �a�kۂ�S��t�CGO��At���Bq�D� /�{em3����x�rG��b�Pu#�YH�8��������!����{ڬ�3t�h�9�t�� �9��'��]� cj�p
1
+ akZ⎏c�I亣4����e�1�x�A�|���%��CZ�:�Jk���㬶��lfTW�9�m��]`�S �k�?���5T�b�QX�������!�����;��f��������*G~iEs�G�V�8l'R&��w��F�KqI�����[�q̸הarSO+���4�\�!�H��ll~� N�p������\�����;$)��C%וژ�G �sW�o�Ŏ��y�s]eexC�t��̄���%�(�vWj�i�k?U�L�F.��9�LD�`a,��1�١�;)�4ykd��^^�}H�S�J�� \�@7���o�k��B��P���e�.����-��g�G~3V� ����X�!|:�v8�I8�ЅFu5fc�0
@@ -24,7 +24,7 @@ jobs:
24
24
  - ruby: '3.2'
25
25
  coverage: 'true'
26
26
  steps:
27
- - uses: actions/checkout@v3
27
+ - uses: actions/checkout@v4
28
28
  - name: Install package dependencies
29
29
  run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
30
30
  - name: Set up Ruby
@@ -49,7 +49,7 @@ jobs:
49
49
  strategy:
50
50
  fail-fast: false
51
51
  steps:
52
- - uses: actions/checkout@v3
52
+ - uses: actions/checkout@v4
53
53
  with:
54
54
  fetch-depth: 0
55
55
  - name: Set up Ruby
@@ -68,7 +68,7 @@ jobs:
68
68
  strategy:
69
69
  fail-fast: false
70
70
  steps:
71
- - uses: actions/checkout@v3
71
+ - uses: actions/checkout@v4
72
72
  with:
73
73
  fetch-depth: 0
74
74
  - name: Run Coditsu
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Karafka core changelog
2
2
 
3
+ ## 2.2.1 (2023-09-10)
4
+ - Optimize statistics decorator by minimizing number of new objects created.
5
+ - Expand the decoration to include new value `_fd` providing freeze duration in milliseconds. This value informs us for how many consecutive ms the given value did not change. It can be useful for detecting values that should change once in a while but are stale.
6
+
3
7
  ## 2.2.0 (2023-09-01)
4
8
  - [Maintenance] Update the signing cert (old expired)
5
9
 
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka-core (2.2.0)
4
+ karafka-core (2.2.1)
5
5
  concurrent-ruby (>= 1.1)
6
6
  karafka-rdkafka (>= 0.13.1, < 0.14.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (7.0.5)
11
+ activesupport (7.0.7.2)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 1.6, < 2)
14
14
  minitest (>= 5.1)
@@ -17,7 +17,7 @@ GEM
17
17
  concurrent-ruby (1.2.2)
18
18
  diff-lcs (1.5.0)
19
19
  docile (1.4.0)
20
- factory_bot (6.2.1)
20
+ factory_bot (6.3.0)
21
21
  activesupport (>= 5.0.0)
22
22
  ffi (1.15.5)
23
23
  i18n (1.14.1)
@@ -27,7 +27,7 @@ GEM
27
27
  mini_portile2 (~> 2.6)
28
28
  rake (> 12)
29
29
  mini_portile2 (2.8.2)
30
- minitest (5.18.0)
30
+ minitest (5.19.0)
31
31
  rake (13.0.6)
32
32
  rspec (3.12.0)
33
33
  rspec-core (~> 3.12.0)
@@ -8,9 +8,26 @@ module Karafka
8
8
  # instead of being a value of messages sent from the last statistics report.
9
9
  # This decorator calculates the diff against previously emited stats, so we get also
10
10
  # the diff together with the original values
11
+ #
12
+ # It adds two extra values to numerics:
13
+ # - KEY_d - delta of the previous value and current
14
+ # - KEY_fd - freeze duration - describes how long the delta remains unchanged (zero)
15
+ # and can be useful for detecting values that "hang" for extended period of time
16
+ # and do not have any change (delta always zero). This value is in ms for the
17
+ # consistency with other time operators we use.
11
18
  class StatisticsDecorator
19
+ include Helpers::Time
20
+
21
+ # Empty hash for internal referencing
22
+ EMPTY_HASH = {}.freeze
23
+
24
+ private_constant :EMPTY_HASH
25
+
12
26
  def initialize
13
- @previous = {}.freeze
27
+ @previous = EMPTY_HASH
28
+ # Operate on ms precision only
29
+ @previous_at = monotonic_now.round
30
+ @current_at = @previous_at
14
31
  end
15
32
 
16
33
  # @param emited_stats [Hash] original emited statistics
@@ -19,12 +36,17 @@ module Karafka
19
36
  # any API to get raw data, users can just assume that the result of this decoration is
20
37
  # the proper raw stats that they can use
21
38
  def call(emited_stats)
39
+ @current_at = monotonic_now.round
40
+
41
+ @change_d = @current_at - @previous_at
42
+
22
43
  diff(
23
44
  @previous,
24
45
  emited_stats
25
46
  )
26
47
 
27
48
  @previous = emited_stats
49
+ @previous_at = @current_at
28
50
 
29
51
  emited_stats.freeze
30
52
  end
@@ -45,7 +67,7 @@ module Karafka
45
67
  append(
46
68
  current,
47
69
  key,
48
- diff((previous || {})[key], (current || {})[key])
70
+ diff((previous || EMPTY_HASH)[key], (current || EMPTY_HASH)[key])
49
71
  )
50
72
  end
51
73
  end
@@ -69,6 +91,15 @@ module Karafka
69
91
  return unless result.is_a?(Numeric)
70
92
  return if current.frozen?
71
93
 
94
+ freeze_duration_key = "#{key}_fd"
95
+
96
+ if result.zero?
97
+ current[freeze_duration_key] ||= 0
98
+ current[freeze_duration_key] += @change_d
99
+ else
100
+ current[freeze_duration_key] = 0
101
+ end
102
+
72
103
  current["#{key}_d"] = result
73
104
  end
74
105
  end
@@ -4,6 +4,6 @@ module Karafka
4
4
  module Core
5
5
  # Current Karafka::Core version
6
6
  # We follow the versioning schema of given Karafka version
7
- VERSION = '2.2.0'
7
+ VERSION = '2.2.1'
8
8
  end
9
9
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
36
36
  msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
37
37
  -----END CERTIFICATE-----
38
- date: 2023-09-01 00:00:00.000000000 Z
38
+ date: 2023-09-10 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: concurrent-ruby
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubygems_version: 3.4.19
151
+ rubygems_version: 3.4.10
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Karafka ecosystem core modules
metadata.gz.sig CHANGED
Binary file