sbmt-kafka_consumer 3.1.0 → 3.2.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: f56ef789be2f19f5e5890292e8163f29d65ced1de23358b3a0bcf4163b77587d
4
- data.tar.gz: 6f7450a9ecf65d6d32294f26142706a7c523af2073be90e9cb9bc6a630ae73f9
3
+ metadata.gz: 884f55960d86ac5b756f5b7defc30298e6918a543a168f69613972b6f4dd1282
4
+ data.tar.gz: 4521497f45d7c2bdf7fb78de36ddba7b077a51aee92c5c7aab41057e9b0e1f5a
5
5
  SHA512:
6
- metadata.gz: 0bab92c52ee0dd45b2893f1e592a480b53c055d2addd522d8ab22bdc8b83068983734974ba56aaf47d370dd6f42b342ec5e1cc8623f8e8a4833ccf112e23bdf2
7
- data.tar.gz: f159851f5089686e1b767f53852257d10575bb4c532e603f8d3a9169f7500556a802bf0e79e60de19c6056d213347782a7334f6a67c5f9ec5f3bc9a2085c472f
6
+ metadata.gz: d25efefade51458b46dd3f060983143f9de35d71d7e007dd082daf5f4a6d8a8a635daff400337d38a8621cdda1ad694e115f4816594cb9f94bd408ec8ddd2b9a
7
+ data.tar.gz: 7fcf377249867d6694515bf006af17de6ade409ddf813bffc63471d437cd1752f659c72d210f071fcf937f6be99f75bf4028e25a3b803d7abfd04e8fd464fdb3
data/CHANGELOG.md CHANGED
@@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
13
13
 
14
14
  ### Fixed
15
15
 
16
+ ## [3.2.0] - 2024-09-17
17
+
18
+ ### Added
19
+
20
+ - For synchronous messages and errors, we place logs in tags
21
+
16
22
  ## [3.1.0] - 2024-09-09
17
23
 
18
24
  ### Fixed
@@ -45,9 +45,7 @@ module Sbmt
45
45
 
46
46
  def with_instrumentation(message)
47
47
  logger.tagged(
48
- trace_id: trace_id,
49
- topic: message.metadata.topic, partition: message.metadata.partition,
50
- key: message.metadata.key, offset: message.metadata.offset
48
+ trace_id: trace_id
51
49
  ) do
52
50
  ::Sbmt::KafkaConsumer.monitor.instrument(
53
51
  "consumer.consumed_one",
@@ -20,30 +20,56 @@ module Sbmt
20
20
 
21
21
  logger.tagged(
22
22
  type: type,
23
+ stacktrace: log_backtrace(error),
23
24
  **tags
24
25
  ) do
25
26
  logger.error(error_message(error))
26
- log_backtrace(error)
27
27
  end
28
28
  end
29
29
 
30
30
  # BaseConsumer events
31
31
  def on_consumer_consumed_one(event)
32
- logger.info("Successfully consumed message in #{event.payload[:time]} ms")
32
+ log_with_tags(log_tags(event), "Successfully consumed message")
33
33
  end
34
34
 
35
35
  def on_consumer_mark_as_consumed(event)
36
- logger.info("Processing message in #{event.payload[:time]} ms")
36
+ log_with_tags(log_tags(event), "Processing message")
37
37
  end
38
38
 
39
39
  def on_consumer_process_message(event)
40
- logger.info("Commit offset in #{event.payload[:time]} ms")
40
+ log_with_tags(log_tags(event), "Commit offset")
41
41
  end
42
42
 
43
43
  # InboxConsumer events
44
44
  def on_consumer_inbox_consumed_one(event)
45
- logger.tagged(status: event[:status]) do
46
- logger.info("Successfully consumed message with uuid: #{event[:message_uuid]} in #{event.payload[:time]} ms")
45
+ log_tags = log_tags(event).merge!(status: event[:status])
46
+ msg = "Successfully consumed message with uuid: #{event[:message_uuid]}"
47
+
48
+ log_with_tags(log_tags, msg)
49
+ end
50
+
51
+ private
52
+
53
+ def log_tags(event)
54
+ metadata = event.payload[:message].metadata
55
+
56
+ {
57
+ kafka: {
58
+ topic: metadata.topic,
59
+ partition: metadata.partition,
60
+ key: metadata.key,
61
+ offset: metadata.offset,
62
+ consumer_group: event.payload[:caller].topic.consumer_group.id,
63
+ consume_duration_ms: event.payload[:time]
64
+ }
65
+ }
66
+ end
67
+
68
+ def log_with_tags(log_tags, msg)
69
+ return unless logger.respond_to?(:tagged)
70
+
71
+ logger.tagged(log_tags) do
72
+ logger.send(:info, msg)
47
73
  end
48
74
  end
49
75
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sbmt
4
4
  module KafkaConsumer
5
- VERSION = "3.1.0"
5
+ VERSION = "3.2.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.1.0
4
+ version: 3.2.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-09-09 00:00:00.000000000 Z
11
+ date: 2024-09-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.3.7
568
+ rubygems_version: 3.1.6
569
569
  signing_key:
570
570
  specification_version: 4
571
571
  summary: Ruby gem for consuming Kafka messages