sbmt-kafka_consumer 3.4.2 → 3.5.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 +4 -4
- data/.rubocop.yml +3 -4
- data/CHANGELOG.md +17 -0
- data/README.md +3 -3
- data/lib/sbmt/kafka_consumer/config/probes/liveness_probe.rb +1 -1
- data/lib/sbmt/kafka_consumer/instrumentation/liveness_listener.rb +19 -39
- data/lib/sbmt/kafka_consumer/instrumentation/yabeda_metrics_listener.rb +2 -2
- data/lib/sbmt/kafka_consumer/probes/host.rb +10 -1
- data/lib/sbmt/kafka_consumer/version.rb +1 -1
- data/lib/sbmt/kafka_consumer/yabeda_configurer.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 872a886b138e7956051e347be06915f7c9153abd50076ae2ae77e0fc83672e48
|
4
|
+
data.tar.gz: 651678b88fe6f8fde83ec4c086dc7bbfcc5edd5ff1dfd214b151bca76f8b3783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b60b4a2a5f84f9e3f6bc7602e352d14a373f49c9bab3d30784259e8a41e01e4d5d4324257a283cec6f3a23169ff47824fbf5c702acab891214c1ba806f2da90
|
7
|
+
data.tar.gz: 2ad55a703d2a6e264d1ceca17335d0a9a6c38250eba00d7c4b8dc4848df1a83442e6c6de1e59916be7ac0de9f3d99114b3c1b0fc0dda24501b8f05d38c867b8f
|
data/.rubocop.yml
CHANGED
@@ -2,10 +2,12 @@ inherit_mode:
|
|
2
2
|
merge:
|
3
3
|
- Exclude
|
4
4
|
|
5
|
-
|
5
|
+
plugins:
|
6
6
|
- rubocop-performance
|
7
7
|
- rubocop-rails
|
8
8
|
- rubocop-rspec
|
9
|
+
|
10
|
+
require:
|
9
11
|
- standard
|
10
12
|
|
11
13
|
inherit_gem:
|
@@ -22,9 +24,6 @@ AllCops:
|
|
22
24
|
Exclude:
|
23
25
|
- spec/internal/pkg/**/*
|
24
26
|
|
25
|
-
RSpec/FilePath:
|
26
|
-
Enabled: false
|
27
|
-
|
28
27
|
RSpec/VerifiedDoubles:
|
29
28
|
Exclude:
|
30
29
|
- spec/**/*_spec.rb
|
data/CHANGELOG.md
CHANGED
@@ -13,6 +13,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
13
13
|
|
14
14
|
### Fixed
|
15
15
|
|
16
|
+
## [3.5.1] - 2025-04-18
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- Rename `yabeda_kafka_consumer_consumer_group_rebalances` gauge to `yabeda_kafka_consumer_group_rebalances`
|
21
|
+
- Change type of `yabeda_kafka_consumer_group_rebalances` from `Counter` to `Gauge`
|
22
|
+
|
23
|
+
## [3.5.0] - 2025-04-17
|
24
|
+
|
25
|
+
### Added
|
26
|
+
|
27
|
+
- Increase default timeout to 300 seconds for better accommodation of temporary delays.
|
28
|
+
- Make liveness probe listener thread-safe using a mutex.
|
29
|
+
- Use monotonic clock for more accurate time measurements in liveness checks.
|
30
|
+
- Simplify liveness status checking logic.
|
31
|
+
- Support Rack v3
|
32
|
+
|
16
33
|
## [3.4.2] - 2025-04-02
|
17
34
|
|
18
35
|
### Fixed
|
data/README.md
CHANGED
@@ -91,7 +91,7 @@ default: &default
|
|
91
91
|
liveness:
|
92
92
|
enabled: true
|
93
93
|
path: "/liveness"
|
94
|
-
timeout:
|
94
|
+
timeout: 300
|
95
95
|
max_error_count: 15 # default 10
|
96
96
|
metrics: # optional section
|
97
97
|
port: 9090
|
@@ -157,7 +157,7 @@ auth:
|
|
157
157
|
The `servers` key is required and should be in rdkafka format: without `kafka://` prefix, for example: `srv1:port1,srv2:port2,...`.
|
158
158
|
|
159
159
|
The `kafka_config` section may contain any [rdkafka option](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md). Also, `kafka_options` may be redefined for each topic.
|
160
|
-
Please note that the `partition.assignment.strategy` option within kafka_options is not supported for topics; instead, use the global option partition_assignment_strategy.
|
160
|
+
Please note that the `partition.assignment.strategy` option within kafka_options is not supported for topics; instead, use the global option partition_assignment_strategy.
|
161
161
|
|
162
162
|
### `consumer_groups` config section
|
163
163
|
|
@@ -275,7 +275,7 @@ To process messages in batches, you need to add the `process_batch` method in th
|
|
275
275
|
# app/consumers/some_consumer.rb
|
276
276
|
class SomeConsumer < Sbmt::KafkaConsumer::BaseConsumer
|
277
277
|
def process_batch(messages)
|
278
|
-
# some code
|
278
|
+
# some code
|
279
279
|
end
|
280
280
|
end
|
281
281
|
```
|
@@ -7,6 +7,6 @@ class Sbmt::KafkaConsumer::Config::Probes::LivenessProbe < Dry::Struct
|
|
7
7
|
attribute :path, Sbmt::KafkaConsumer::Types::Strict::String
|
8
8
|
.optional
|
9
9
|
.default("/liveness")
|
10
|
-
attribute :timeout, Sbmt::KafkaConsumer::Types::Coercible::Integer.optional.default(
|
10
|
+
attribute :timeout, Sbmt::KafkaConsumer::Types::Coercible::Integer.optional.default(300)
|
11
11
|
attribute :max_error_count, Sbmt::KafkaConsumer::Types::Coercible::Integer.optional.default(10)
|
12
12
|
end
|
@@ -9,33 +9,35 @@ module Sbmt
|
|
9
9
|
|
10
10
|
ERROR_TYPE = "Liveness probe error"
|
11
11
|
|
12
|
-
def initialize(timeout_sec:
|
13
|
-
@
|
14
|
-
@timeout_sec = timeout_sec
|
12
|
+
def initialize(timeout_sec: 300, max_error_count: 10)
|
13
|
+
@timeout_sec = timeout_sec * 1000
|
15
14
|
@max_error_count = max_error_count
|
16
15
|
@error_count = 0
|
17
16
|
@error_backtrace = nil
|
18
17
|
@polls = {}
|
19
|
-
|
18
|
+
@mutex = Mutex.new
|
20
19
|
setup_subscription
|
21
20
|
end
|
22
21
|
|
23
22
|
def probe(_env)
|
24
|
-
now =
|
25
|
-
|
23
|
+
now = monotonic_now
|
24
|
+
has_timed_out_polls = polls.values.any? { |tick| (now - tick) > timeout_sec }
|
26
25
|
|
27
|
-
if
|
28
|
-
probe_ok
|
26
|
+
if !has_timed_out_polls && @error_count < @max_error_count
|
27
|
+
probe_ok timed_out_polls: false, errors_count: @error_count
|
29
28
|
elsif @error_count >= @max_error_count
|
30
|
-
probe_error error_type: ERROR_TYPE,
|
29
|
+
probe_error error_type: ERROR_TYPE, timed_out_polls: false, error_count: @error_count, error_backtrace: @error_backtrace
|
31
30
|
else
|
32
|
-
probe_error error_type: ERROR_TYPE,
|
31
|
+
probe_error error_type: ERROR_TYPE, timed_out_polls: true, errors_count: @error_count, polls: polls
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
36
35
|
def on_connection_listener_fetch_loop(event)
|
37
|
-
|
38
|
-
|
36
|
+
now = monotonic_now
|
37
|
+
KafkaConsumer.logger.debug("on_connection_listener_fetch_loop: now=#{now}, thread_id=#{thread_id}")
|
38
|
+
mutex.synchronize do
|
39
|
+
polls[thread_id] = monotonic_now
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
def on_error_occurred(event)
|
@@ -50,36 +52,14 @@ module Sbmt
|
|
50
52
|
|
51
53
|
private
|
52
54
|
|
53
|
-
attr_reader :polls, :timeout_sec, :
|
55
|
+
attr_reader :polls, :timeout_sec, :mutex
|
54
56
|
|
55
|
-
def
|
56
|
-
|
57
|
+
def monotonic_now
|
58
|
+
::Process.clock_gettime(::Process::CLOCK_MONOTONIC, :float_millisecond)
|
57
59
|
end
|
58
60
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
62
|
-
consumer_groups.each_with_object({}) do |group, hash|
|
63
|
-
last_poll_at = polls[group]
|
64
|
-
next if last_poll_at && last_poll_at + timeout_sec >= now
|
65
|
-
|
66
|
-
hash[group] = last_poll_at
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def meta_from_polls(polls, now)
|
71
|
-
polls.each_with_object({}) do |(group, last_poll_at), hash|
|
72
|
-
if last_poll_at.nil?
|
73
|
-
hash[group] = {had_poll: false}
|
74
|
-
next
|
75
|
-
end
|
76
|
-
|
77
|
-
hash[group] = {
|
78
|
-
had_poll: true,
|
79
|
-
last_poll_at: last_poll_at,
|
80
|
-
seconds_since_last_poll: (now - last_poll_at).to_i
|
81
|
-
}
|
82
|
-
end
|
61
|
+
def thread_id
|
62
|
+
Thread.current.object_id
|
83
63
|
end
|
84
64
|
|
85
65
|
def setup_subscription
|
@@ -150,8 +150,8 @@ module Sbmt
|
|
150
150
|
state: group_stats["state"]
|
151
151
|
}
|
152
152
|
|
153
|
-
Yabeda.kafka_consumer.
|
154
|
-
.
|
153
|
+
Yabeda.kafka_consumer.group_rebalances
|
154
|
+
.set(cg_tags, group_stats["rebalance_cnt"])
|
155
155
|
end
|
156
156
|
|
157
157
|
def report_topic_stats(group_id, topic_stats)
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "rack"
|
4
|
+
require "rackup/handler/webrick" if Gem::Version.new(::Rack.release) >= Gem::Version.new("3")
|
5
|
+
|
3
6
|
module Sbmt
|
4
7
|
module KafkaConsumer
|
5
8
|
module Probes
|
@@ -14,6 +17,12 @@ module Sbmt
|
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
20
|
+
def webrick
|
21
|
+
return ::Rack::Handler::WEBrick if Gem::Version.new(::Rack.release) < Gem::Version.new("3")
|
22
|
+
|
23
|
+
::Rackup::Handler::WEBrick
|
24
|
+
end
|
25
|
+
|
17
26
|
private
|
18
27
|
|
19
28
|
def health_check_app(config)
|
@@ -56,7 +65,7 @@ module Sbmt
|
|
56
65
|
|
57
66
|
def start_webrick(app, middlewares:, port:)
|
58
67
|
Thread.new do
|
59
|
-
|
68
|
+
webrick.run(
|
60
69
|
::Rack::Builder.new do
|
61
70
|
middlewares.each do |middleware, options|
|
62
71
|
use middleware, **options
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbmt-kafka_consumer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kuper Ruby-Platform Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -565,7 +565,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
565
565
|
- !ruby/object:Gem::Version
|
566
566
|
version: '0'
|
567
567
|
requirements: []
|
568
|
-
rubygems_version: 3.
|
568
|
+
rubygems_version: 3.5.21
|
569
569
|
signing_key:
|
570
570
|
specification_version: 4
|
571
571
|
summary: Ruby gem for consuming Kafka messages
|