waterdrop 2.6.4 → 2.6.6
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 +7 -1
- data/Gemfile.lock +1 -1
- data/README.md +29 -0
- data/lib/waterdrop/instrumentation/logger_listener.rb +39 -1
- data/lib/waterdrop/producer/async.rb +14 -10
- data/lib/waterdrop/producer/sync.rb +14 -10
- data/lib/waterdrop/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -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: b8230d88044bf8542a887da74a67273ac3599918e108b0c30694b8fe38910c4e
|
4
|
+
data.tar.gz: 39e1aff3939c76ca14cb967148fb8328af148098cd3215cd921190c40b95efdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5018e5ede943b48093b871381757aeb2b6af92248181ff3a8dd954a2c40e3cc123515dbb71dd7b0f33e1107c500711be6dcb252552e0ecd348e0fad292c2700c
|
7
|
+
data.tar.gz: 06c00dfe2cd6d7b37455a8b8f5f6613e161620535138fe53dc304b5e7fc1cad835ed0b8f2a86e71ffbb840c39f85bf7897eab227b2ce2671995ef15e07f666a8
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# WaterDrop changelog
|
2
2
|
|
3
|
-
### 2.6.
|
3
|
+
### 2.6.6 (2023-08-03)
|
4
|
+
- [Improvement] Provide `log_messages` option to `LoggerListener` so the extensive messages data logging can disabled.
|
5
|
+
|
6
|
+
### 2.6.5 (2023-07-22)
|
7
|
+
- [Fix] Add cause to the errors that are passed into instrumentation (konalegi)
|
8
|
+
|
9
|
+
### 2.6.4 (2023-07-11)
|
4
10
|
- [Improvement] Use original error `#inspect` for `WaterDrop::Errors::ProduceError` and `WaterDrop::Errors::ProduceManyError` instead of the current empty string.
|
5
11
|
|
6
12
|
### 2.6.3 (2023-06-28)
|
data/Gemfile.lock
CHANGED
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
|
-
|
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)
|
@@ -23,17 +23,21 @@ module WaterDrop
|
|
23
23
|
message: message
|
24
24
|
) { produce(message) }
|
25
25
|
rescue *SUPPORTED_FLOW_ERRORS => e
|
26
|
-
|
26
|
+
# We use this syntax here because we want to preserve the original `#cause` when we
|
27
|
+
# instrument the error and there is no way to manually assign `#cause` value
|
28
|
+
begin
|
29
|
+
raise Errors::ProduceError, e.inspect
|
30
|
+
rescue Errors::ProduceError => ex
|
31
|
+
@monitor.instrument(
|
32
|
+
'error.occurred',
|
33
|
+
producer_id: id,
|
34
|
+
message: message,
|
35
|
+
error: ex,
|
36
|
+
type: 'message.produce_async'
|
37
|
+
)
|
27
38
|
|
28
|
-
|
29
|
-
|
30
|
-
producer_id: id,
|
31
|
-
message: message,
|
32
|
-
error: re_raised,
|
33
|
-
type: 'message.produce_async'
|
34
|
-
)
|
35
|
-
|
36
|
-
raise re_raised
|
39
|
+
raise ex
|
40
|
+
end
|
37
41
|
end
|
38
42
|
|
39
43
|
# Produces many messages to Kafka and does not wait for them to be delivered
|
@@ -27,17 +27,21 @@ module WaterDrop
|
|
27
27
|
wait(produce(message))
|
28
28
|
end
|
29
29
|
rescue *SUPPORTED_FLOW_ERRORS => e
|
30
|
-
|
30
|
+
# We use this syntax here because we want to preserve the original `#cause` when we
|
31
|
+
# instrument the error and there is no way to manually assign `#cause` value
|
32
|
+
begin
|
33
|
+
raise Errors::ProduceError, e.inspect
|
34
|
+
rescue Errors::ProduceError => ex
|
35
|
+
@monitor.instrument(
|
36
|
+
'error.occurred',
|
37
|
+
producer_id: id,
|
38
|
+
message: message,
|
39
|
+
error: ex,
|
40
|
+
type: 'message.produce_sync'
|
41
|
+
)
|
31
42
|
|
32
|
-
|
33
|
-
|
34
|
-
producer_id: id,
|
35
|
-
message: message,
|
36
|
-
error: re_raised,
|
37
|
-
type: 'message.produce_sync'
|
38
|
-
)
|
39
|
-
|
40
|
-
raise re_raised
|
43
|
+
raise ex
|
44
|
+
end
|
41
45
|
end
|
42
46
|
|
43
47
|
# Produces many messages to Kafka and waits for them to be delivered
|
data/lib/waterdrop/version.rb
CHANGED
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.
|
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-
|
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
|