karafka-core 2.2.0 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/workflows/ci.yml +3 -3
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +4 -4
- data/lib/karafka/core/monitoring/statistics_decorator.rb +40 -4
- data/lib/karafka/core/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 267d7bea7b3b01122363dfe4d2157f9e400b89b375a8f21c61e913dfb54b89e6
|
4
|
+
data.tar.gz: f5b5b6d2b0e253aa3df2444fbd02aebae91b232e66b836f895128173eab481af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d5a57339a3259cd1561af52e33eb31b592d8e7b59201d3394a8f58f75ddd5c8acd835b94a8c9d50a93f48137191a5bb9d0570002234f2593652ed16b76a9b81
|
7
|
+
data.tar.gz: 3d00d4800f4c9ac425fd3f951b7bdee94a407a23d009c921f2c64799f32e36ea936814235dec0df922941036361c500e65fcda210aaf983c38ec9f3bf00c09e5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.github/workflows/ci.yml
CHANGED
@@ -24,7 +24,7 @@ jobs:
|
|
24
24
|
- ruby: '3.2'
|
25
25
|
coverage: 'true'
|
26
26
|
steps:
|
27
|
-
- uses: actions/checkout@
|
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@
|
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@
|
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,12 @@
|
|
1
1
|
# Karafka core changelog
|
2
2
|
|
3
|
+
### 2.2.2 (2023-09-11)
|
4
|
+
- [Fix] Reuse previous frozen duration as a base for incoming computation.
|
5
|
+
|
6
|
+
## 2.2.1 (2023-09-10)
|
7
|
+
- Optimize statistics decorator by minimizing number of new objects created.
|
8
|
+
- 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.
|
9
|
+
|
3
10
|
## 2.2.0 (2023-09-01)
|
4
11
|
- [Maintenance] Update the signing cert (old expired)
|
5
12
|
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
karafka-core (2.2.
|
4
|
+
karafka-core (2.2.2)
|
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.
|
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.
|
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.
|
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 =
|
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
|
@@ -39,13 +61,17 @@ module Karafka
|
|
39
61
|
# @return [Object] the diff if the values were numerics or the current scope
|
40
62
|
def diff(previous, current)
|
41
63
|
if current.is_a?(Hash)
|
64
|
+
filled_previous = previous || EMPTY_HASH
|
65
|
+
filled_current = current || EMPTY_HASH
|
66
|
+
|
42
67
|
# @note We cannot use #each_key as we modify the content of the current scope
|
43
68
|
# in place (in case it's a hash)
|
44
69
|
current.keys.each do |key|
|
45
70
|
append(
|
46
|
-
|
71
|
+
filled_previous,
|
72
|
+
filled_current,
|
47
73
|
key,
|
48
|
-
diff(
|
74
|
+
diff(filled_previous[key], filled_current[key])
|
49
75
|
)
|
50
76
|
end
|
51
77
|
end
|
@@ -62,13 +88,23 @@ module Karafka
|
|
62
88
|
|
63
89
|
# Appends the result of the diff to a given key as long as the result is numeric
|
64
90
|
#
|
91
|
+
# @param previous [Hash] previous scope
|
65
92
|
# @param current [Hash] current scope
|
66
93
|
# @param key [Symbol] key based on which we were diffing
|
67
94
|
# @param result [Object] diff result
|
68
|
-
def append(current, key, result)
|
95
|
+
def append(previous, current, key, result)
|
69
96
|
return unless result.is_a?(Numeric)
|
70
97
|
return if current.frozen?
|
71
98
|
|
99
|
+
freeze_duration_key = "#{key}_fd"
|
100
|
+
|
101
|
+
if result.zero?
|
102
|
+
current[freeze_duration_key] = previous[freeze_duration_key] || 0
|
103
|
+
current[freeze_duration_key] += @change_d
|
104
|
+
else
|
105
|
+
current[freeze_duration_key] = 0
|
106
|
+
end
|
107
|
+
|
72
108
|
current["#{key}_d"] = result
|
73
109
|
end
|
74
110
|
end
|
data/lib/karafka/core/version.rb
CHANGED
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.
|
4
|
+
version: 2.2.2
|
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-
|
38
|
+
date: 2023-09-11 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: concurrent-ruby
|
metadata.gz.sig
CHANGED
Binary file
|