sbmt-kafka_consumer 3.3.2 → 3.4.0

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: 7918960487cca5e2c992726b0ff8b431e855abb11775645ea5562de36aea17e1
4
- data.tar.gz: 526a797e57595ad90658b21c3a419b2e21884918c66669e922e10f0cfe11d696
3
+ metadata.gz: 114637de2c62e2a36a3221b5f754d2df112956b2083732bc21f2addffbe6b1df
4
+ data.tar.gz: d119ec787d1129ba9872dfd4d3a64ae6b2cc0f0f9fa8abe32e7da4210d356e34
5
5
  SHA512:
6
- metadata.gz: 529347ea9e8e886e442f8bbde28ce1a801691a200f735936aa032364418d35799a3c601df28e30c897cec71049f5e4ab146cfeaf014257c41715e0c818d9ded8
7
- data.tar.gz: 3d1a36773274f20fedb611c644cac723826216d4b730027f0267cf5cd3ced59df111e7d5dc33c61416d399ecb528003f03416479e384a4f185a59ea40ee03388
6
+ metadata.gz: c9158965a771af77ece756acbba753098f76a77f557813dfcd6256121d38054985ea7d251b05c21bfdca0ed0111305ef17bca3c54e1b3c1859a88e220c4712d9
7
+ data.tar.gz: 89c5aebdd80c7f72169880491727ba22bdb6d9d22d85b01c8d489a36d94dea971d878b4fec3dae9b6a251c700d41709274924466a812b0659f54c93cba3abecc
data/CHANGELOG.md CHANGED
@@ -13,6 +13,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
13
13
 
14
14
  ### Fixed
15
15
 
16
+ ## [3.4.0] - 2025-01-27
17
+
18
+ ### Added
19
+
20
+ - Added support for warning log level in LoggerListener error handling
21
+ - Consider duplicate messages as warnings in logs
22
+
23
+ ### Changed
24
+
25
+ ### Fixed
26
+
16
27
  ## [3.3.2] - 2024-12-27
17
28
 
18
29
  ### Fixed
@@ -32,20 +43,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
32
43
  - inheritance of kafka settings for topic
33
44
 
34
45
  ### Fixed
35
-
46
+
36
47
  - support `karafka 2.4.12`
37
48
  - properly report metrics for consumer offset lag when partition fetch assignment was lost
38
49
 
39
50
  ## [3.2.2] - 2024-09-23
40
51
 
41
52
  ### Fixed
42
-
53
+
43
54
  - log OTEL `trace_id`
44
55
 
45
56
  ## [3.2.1] - 2024-09-20
46
57
 
47
58
  ### Fixed
48
-
59
+
49
60
  - Limit Karafka version to less than 2.4.12 since `bootstrap.servers` has been made required
50
61
 
51
62
  ## [3.2.0] - 2024-09-17
@@ -138,7 +138,8 @@ module Sbmt
138
138
  error: error,
139
139
  caller: self,
140
140
  message: message,
141
- type: "consumer.base.consume_one"
141
+ type: "consumer.base.consume_one",
142
+ log_level: :error
142
143
  )
143
144
  end
144
145
 
@@ -56,7 +56,7 @@ module Sbmt
56
56
  item = result.success
57
57
  item.track_metrics_after_consume if item.respond_to?(:track_metrics_after_consume)
58
58
  rescue ActiveRecord::RecordNotUnique
59
- instrument_error("Skipped duplicate message for #{inbox_name}, message_uuid: #{message_uuid(message)}", message, "duplicate")
59
+ instrument_warn("Skipped duplicate message for #{inbox_name}, message_uuid: #{message_uuid(message)}", message, "duplicate")
60
60
  rescue => ex
61
61
  if skip_on_error
62
62
  logger.warn("skipping unprocessable message for #{inbox_name}, message_uuid: #{message_uuid(message)}")
@@ -108,7 +108,7 @@ module Sbmt
108
108
  inbox_item_class.box_name
109
109
  end
110
110
 
111
- def instrument_error(error, message, status = "failure")
111
+ def instrument_error(error, message, status = "failure", log_level: :error)
112
112
  ::Sbmt::KafkaConsumer.monitor.instrument(
113
113
  "error.occurred",
114
114
  error: error,
@@ -117,9 +117,14 @@ module Sbmt
117
117
  inbox_name: inbox_name,
118
118
  event_name: event_name,
119
119
  status: status,
120
- type: "consumer.inbox.consume_one"
120
+ type: "consumer.inbox.consume_one",
121
+ log_level: log_level
121
122
  )
122
123
  end
124
+
125
+ def instrument_warn(*args, **kwargs)
126
+ instrument_error(*args, **kwargs, log_level: :warn)
127
+ end
123
128
  end
124
129
  end
125
130
  end
@@ -6,6 +6,7 @@ module Sbmt
6
6
  class LoggerListener < Karafka::Instrumentation::LoggerListener
7
7
  include ListenerHelper
8
8
  CUSTOM_ERROR_TYPES = %w[consumer.base.consume_one consumer.inbox.consume_one].freeze
9
+ VALID_LOG_LEVELS = %i[error warn].freeze
9
10
 
10
11
  def on_error_occurred(event)
11
12
  type = event[:type]
@@ -23,7 +24,12 @@ module Sbmt
23
24
  stacktrace: log_backtrace(error),
24
25
  **tags
25
26
  ) do
26
- logger.error(error_message(error))
27
+ log_level = event[:log_level] || :error
28
+ if VALID_LOG_LEVELS.include?(log_level)
29
+ logger.public_send(log_level, error_message(error))
30
+ else
31
+ raise "Invalid log level #{log_level}"
32
+ end
27
33
  end
28
34
  end
29
35
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sbmt
4
4
  module KafkaConsumer
5
- VERSION = "3.3.2"
5
+ VERSION = "3.4.0"
6
6
  end
7
7
  end
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.3.2
4
+ version: 3.4.0
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: 2024-12-27 00:00:00.000000000 Z
11
+ date: 2025-01-29 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.1.6
568
+ rubygems_version: 3.5.21
569
569
  signing_key:
570
570
  specification_version: 4
571
571
  summary: Ruby gem for consuming Kafka messages