waterdrop 2.6.5 → 2.6.6

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: 908779a6b04cc938fc6f2801d1cd8650191a8cc61db1cda5e8331ca31b2a044e
4
- data.tar.gz: 610c8c9e35cc0bd8f1ac47ad34e8e5c36e10283806085c10797ca61cf1761a06
3
+ metadata.gz: b8230d88044bf8542a887da74a67273ac3599918e108b0c30694b8fe38910c4e
4
+ data.tar.gz: 39e1aff3939c76ca14cb967148fb8328af148098cd3215cd921190c40b95efdc
5
5
  SHA512:
6
- metadata.gz: 8274e596617d0ba318948f11dda305e8e36819a2f499b8344536a769b576439fcb9a99daaa759d33d2a25629586a5bbff99259ded9682931a8fb5be6357bb2fd
7
- data.tar.gz: 9931e5cff829a95398adeac12e22a8461ac3abb0b0001829876495e53b66489ef13896dea7106624602bc1ddc2abcacf2bbd3df107266cbf99c69e5ca84e7e05
6
+ metadata.gz: 5018e5ede943b48093b871381757aeb2b6af92248181ff3a8dd954a2c40e3cc123515dbb71dd7b0f33e1107c500711be6dcb252552e0ecd348e0fad292c2700c
7
+ data.tar.gz: 06c00dfe2cd6d7b37455a8b8f5f6613e161620535138fe53dc304b5e7fc1cad835ed0b8f2a86e71ffbb840c39f85bf7897eab227b2ce2671995ef15e07f666a8
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # WaterDrop changelog
2
2
 
3
+ ### 2.6.6 (2023-08-03)
4
+ - [Improvement] Provide `log_messages` option to `LoggerListener` so the extensive messages data logging can disabled.
5
+
3
6
  ### 2.6.5 (2023-07-22)
4
7
  - [Fix] Add cause to the errors that are passed into instrumentation (konalegi)
5
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- waterdrop (2.6.5)
4
+ waterdrop (2.6.6)
5
5
  karafka-core (>= 2.1.1, < 3.0.0)
6
6
  zeitwerk (~> 2.3)
7
7
 
data/README.md CHANGED
@@ -339,6 +339,35 @@ Karafka [Web UI](https://karafka.io/docs/Web-UI-Getting-Started/) is a user inte
339
339
 
340
340
  ![Example producer errors in Karafka Web-UI](https://raw.githubusercontent.com/karafka/misc/master/printscreens/web-ui/errors-producer.png)
341
341
 
342
+ ### Logger Listener
343
+
344
+ WaterDrop comes equipped with a `LoggerListener`, a useful feature designed to facilitate the reporting of WaterDrop's operational details directly into the assigned logger. The `LoggerListener` provides a convenient way of tracking the events and operations that occur during the usage of WaterDrop, enhancing transparency and making debugging and issue tracking easier.
345
+
346
+ However, it's important to note that this Logger Listener is not subscribed by default. This means that WaterDrop does not automatically send operation data to your logger out of the box. This design choice has been made to give users greater flexibility and control over their logging configuration.
347
+
348
+ To use this functionality, you need to manually subscribe the `LoggerListener` to WaterDrop instrumentation. Below, you will find an example demonstrating how to perform this subscription.
349
+
350
+ ```ruby
351
+ LOGGER = Logger.new($stdout)
352
+
353
+ producer = WaterDrop::Producer.new do |config|
354
+ config.kafka = { 'bootstrap.servers': 'localhost:9092' }
355
+ config.logger = LOGGER
356
+ end
357
+
358
+ producer.monitor.subscribe(
359
+ WaterDrop::Instrumentation::LoggerListener.new(
360
+ # You can use a different logger than the one assigned to WaterDrop if you want
361
+ producer.config.logger,
362
+ # If this is set to false, the produced messages details will not be sent to logs
363
+ # You may set it to false if you find the level of reporting in the debug too extensive
364
+ log_messages: true
365
+ )
366
+ )
367
+
368
+ producer.produce_sync(topic: 'my.topic', payload: 'my.message')
369
+ ```
370
+
342
371
  ### Usage statistics
343
372
 
344
373
  WaterDrop is configured to emit internal `librdkafka` metrics every five seconds. You can change this by setting the `kafka` `statistics.interval.ms` configuration property to a value greater of equal `0`. Emitted statistics are available after subscribing to the `statistics.emitted` publisher event. If set to `0`, metrics will not be published.
@@ -9,8 +9,17 @@ module WaterDrop
9
9
  # as well as we can use it standalone
10
10
  class LoggerListener
11
11
  # @param logger [Object] logger we want to use
12
- def initialize(logger)
12
+ # @param log_messages [Boolean] Should we report the messages content (payload and metadata)
13
+ # with each message operation.
14
+ #
15
+ # This can be extensive, especially when producing a lot of messages. We provide this
16
+ # despite the fact that we only report payloads in debug, because Rails by default operates
17
+ # with debug level. This means, that when working with Rails in development, every single
18
+ # payload dispatched will go to logs. In majority of the cases this is extensive and simply
19
+ # floods the end user.
20
+ def initialize(logger, log_messages: true)
13
21
  @logger = logger
22
+ @log_messages = log_messages
14
23
  end
15
24
 
16
25
  # @param event [Dry::Events::Event] event that happened with the details
@@ -18,6 +27,9 @@ module WaterDrop
18
27
  message = event[:message]
19
28
 
20
29
  info(event, "Async producing of a message to '#{message[:topic]}' topic")
30
+
31
+ return unless log_messages?
32
+
21
33
  debug(event, message)
22
34
  end
23
35
 
@@ -26,6 +38,9 @@ module WaterDrop
26
38
  message = event[:message]
27
39
 
28
40
  info(event, "Sync producing of a message to '#{message[:topic]}' topic")
41
+
42
+ return unless log_messages?
43
+
29
44
  debug(event, message)
30
45
  end
31
46
 
@@ -35,6 +50,9 @@ module WaterDrop
35
50
  topics_count = messages.map { |message| "'#{message[:topic]}'" }.uniq.count
36
51
 
37
52
  info(event, "Async producing of #{messages.size} messages to #{topics_count} topics")
53
+
54
+ return unless log_messages?
55
+
38
56
  debug(event, messages)
39
57
  end
40
58
 
@@ -44,6 +62,9 @@ module WaterDrop
44
62
  topics_count = messages.map { |message| "'#{message[:topic]}'" }.uniq.count
45
63
 
46
64
  info(event, "Sync producing of #{messages.size} messages to #{topics_count} topics")
65
+
66
+ return unless log_messages?
67
+
47
68
  debug(event, messages)
48
69
  end
49
70
 
@@ -52,6 +73,9 @@ module WaterDrop
52
73
  message = event[:message]
53
74
 
54
75
  info(event, "Buffering of a message to '#{message[:topic]}' topic")
76
+
77
+ return unless log_messages?
78
+
55
79
  debug(event, [message])
56
80
  end
57
81
 
@@ -60,6 +84,9 @@ module WaterDrop
60
84
  messages = event[:messages]
61
85
 
62
86
  info(event, "Buffering of #{messages.size} messages")
87
+
88
+ return unless log_messages?
89
+
63
90
  debug(event, [messages, messages.size])
64
91
  end
65
92
 
@@ -68,6 +95,9 @@ module WaterDrop
68
95
  messages = event[:messages]
69
96
 
70
97
  info(event, "Async flushing of #{messages.size} messages from the buffer")
98
+
99
+ return unless log_messages?
100
+
71
101
  debug(event, messages)
72
102
  end
73
103
 
@@ -76,6 +106,9 @@ module WaterDrop
76
106
  messages = event[:messages]
77
107
 
78
108
  info(event, "Sync flushing of #{messages.size} messages from the buffer")
109
+
110
+ return unless log_messages?
111
+
79
112
  debug(event, messages)
80
113
  end
81
114
 
@@ -94,6 +127,11 @@ module WaterDrop
94
127
 
95
128
  private
96
129
 
130
+ # @return [Boolean] should we report the messages details in the debug mode.
131
+ def log_messages?
132
+ @log_messages
133
+ end
134
+
97
135
  # @param event [Dry::Events::Event] event that happened with the details
98
136
  # @param log_message [String] message we want to publish
99
137
  def debug(event, log_message)
@@ -3,5 +3,5 @@
3
3
  # WaterDrop library
4
4
  module WaterDrop
5
5
  # Current WaterDrop version
6
- VERSION = '2.6.5'
6
+ VERSION = '2.6.6'
7
7
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waterdrop
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.5
4
+ version: 2.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  Qf04B9ceLUaC4fPVEz10FyobjaFoY4i32xRto3XnrzeAgfEe4swLq8bQsR3w/EF3
36
36
  MGU0FeSV2Yj7Xc2x/7BzLK8xQn5l7Yy75iPF+KP3vVmDHnNl
37
37
  -----END CERTIFICATE-----
38
- date: 2023-07-22 00:00:00.000000000 Z
38
+ date: 2023-08-03 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka-core
metadata.gz.sig CHANGED
Binary file