karafka-core 2.0.1 → 2.0.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/CHANGELOG.md +5 -2
- data/Gemfile.lock +1 -1
- data/lib/karafka/core/monitoring/statistics_decorator.rb +77 -0
- data/lib/karafka/core/version.rb +1 -1
- data/lib/karafka-core.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +3 -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: f3932e3ec9d159f2be8ba43d231197c00770409693e712a6a14f7893aa5671fc
|
4
|
+
data.tar.gz: 86b27fc05550881f80f7d3db32d4e7cd3fcd48b8792d87413d6887ca19722d3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c017f02c04db51ea04a7686a41974622006c0a6eaf07aeaa9edbd7f9e6b32fcca14edf8215da67a9f50d52237c455a3242e900994a9444df833eebf606de74c6
|
7
|
+
data.tar.gz: e07af5f18d2f158209afa0c9615cc2d2459edb4d89a5b4534e9424e3d2243decd1bff316fc7a03556478b9f3f2b1afe5d20cf5367eaa93376350005b6711f158
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# Karafka core changelog
|
2
2
|
|
3
|
-
## 2.0.
|
3
|
+
## 2.0.2 (2022-08-01)
|
4
|
+
- Add extracted statistics decorator (#932)
|
5
|
+
|
6
|
+
## 2.0.1 (2022-07-30)
|
4
7
|
- Fix a case where setting would match a method monkey-patched on an object (#1) causing initializers not to build proper accessors on nodes. This is not the core bug, but still worth handling this case.
|
5
8
|
|
6
|
-
## 2.0.0
|
9
|
+
## 2.0.0 (2022-07-28)
|
7
10
|
- Initial extraction of common components used in the Karafka ecosystem from WaterDrop.
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Karafka
|
4
|
+
module Core
|
5
|
+
module Monitoring
|
6
|
+
# Many of the librdkafka statistics are absolute values instead of a gauge.
|
7
|
+
# This means, that for example number of messages sent is an absolute growing value
|
8
|
+
# instead of being a value of messages sent from the last statistics report.
|
9
|
+
# This decorator calculates the diff against previously emited stats, so we get also
|
10
|
+
# the diff together with the original values
|
11
|
+
class StatisticsDecorator
|
12
|
+
def initialize
|
13
|
+
@previous = {}.freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
# @param emited_stats [Hash] original emited statistics
|
17
|
+
# @return [Hash] emited statistics extended with the diff data
|
18
|
+
# @note We modify the emited statistics, instead of creating new. Since we don't expose
|
19
|
+
# any API to get raw data, users can just assume that the result of this decoration is
|
20
|
+
# the proper raw stats that they can use
|
21
|
+
def call(emited_stats)
|
22
|
+
diff(
|
23
|
+
@previous,
|
24
|
+
emited_stats
|
25
|
+
)
|
26
|
+
|
27
|
+
@previous = emited_stats
|
28
|
+
|
29
|
+
emited_stats.freeze
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# Calculates the diff of the provided values and modifies in place the emited statistics
|
35
|
+
#
|
36
|
+
# @param previous [Object] previous value from the given scope in which
|
37
|
+
# we are
|
38
|
+
# @param current [Object] current scope from emitted statistics
|
39
|
+
# @return [Object] the diff if the values were numerics or the current scope
|
40
|
+
def diff(previous, current)
|
41
|
+
if current.is_a?(Hash)
|
42
|
+
# @note We cannot use #each_key as we modify the content of the current scope
|
43
|
+
# in place (in case it's a hash)
|
44
|
+
current.keys.each do |key|
|
45
|
+
append(
|
46
|
+
current,
|
47
|
+
key,
|
48
|
+
diff((previous || {})[key], (current || {})[key])
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Diff can be computed only for numerics
|
54
|
+
return current unless current.is_a?(Numeric)
|
55
|
+
# If there was no previous value, delta is always zero
|
56
|
+
return 0 unless previous
|
57
|
+
# Should never happen but just in case, a type changed in between stats
|
58
|
+
return current unless previous.is_a?(Numeric)
|
59
|
+
|
60
|
+
current - previous
|
61
|
+
end
|
62
|
+
|
63
|
+
# Appends the result of the diff to a given key as long as the result is numeric
|
64
|
+
#
|
65
|
+
# @param current [Hash] current scope
|
66
|
+
# @param key [Symbol] key based on which we were diffing
|
67
|
+
# @param result [Object] diff result
|
68
|
+
def append(current, key, result)
|
69
|
+
return unless result.is_a?(Numeric)
|
70
|
+
return if current.frozen?
|
71
|
+
|
72
|
+
current["#{key}_d"] = result
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/karafka/core/version.rb
CHANGED
data/lib/karafka-core.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.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Mensfeld
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
R2P11bWoCtr70BsccVrN8jEhzwXngMyI2gVt750Y+dbTu1KgRqZKp/ECe7ZzPzXj
|
35
35
|
pIy9vHxTANKYVyI4qj8OrFdEM5BQNu8oQpL0iQ==
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2022-
|
37
|
+
date: 2022-08-01 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: concurrent-ruby
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/karafka/core/monitoring/event.rb
|
90
90
|
- lib/karafka/core/monitoring/monitor.rb
|
91
91
|
- lib/karafka/core/monitoring/notifications.rb
|
92
|
+
- lib/karafka/core/monitoring/statistics_decorator.rb
|
92
93
|
- lib/karafka/core/version.rb
|
93
94
|
- log/.gitkeep
|
94
95
|
homepage: https://karafka.io
|
metadata.gz.sig
CHANGED
Binary file
|