Class: WaterDrop::Instrumentation::StdoutListener
- Inherits:
-
Object
- Object
- WaterDrop::Instrumentation::StdoutListener
- Defined in:
- lib/water_drop/instrumentation/stdout_listener.rb
Overview
Note:
It is a module as we can use it then as a part of the Karafka framework listener as well as we can use it standalone
Default listener that hooks up to our instrumentation and uses its events for logging It can be removed/replaced or anything without any harm to the Waterdrop flow
Instance Method Summary collapse
-
#initialize(logger) ⇒ StdoutListener
constructor
A new instance of StdoutListener.
- #on_buffer_flushed_async(event) ⇒ Object
- #on_buffer_flushed_async_error(event) ⇒ Object
- #on_buffer_flushed_sync(event) ⇒ Object
- #on_buffer_flushed_sync_error(event) ⇒ Object
- #on_message_buffered(event) ⇒ Object
- #on_message_produced_async(event) ⇒ Object
- #on_message_produced_sync(event) ⇒ Object
- #on_messages_buffered(event) ⇒ Object
- #on_messages_produced_async(event) ⇒ Object
- #on_messages_produced_sync(event) ⇒ Object
- #on_producer_closed(event) ⇒ Object
Constructor Details
#initialize(logger) ⇒ StdoutListener
Returns a new instance of StdoutListener.
11 12 13 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 11 def initialize(logger) @logger = logger end |
Instance Method Details
#on_buffer_flushed_async(event) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 66 def on_buffer_flushed_async(event) = event[:messages] info(event, "Async flushing of #{.size} messages from the buffer") debug(event, ) end |
#on_buffer_flushed_async_error(event) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 74 def on_buffer_flushed_async_error(event) = event[:messages] error = event[:error] error(event, "Async flushing of #{.size} failed due to: #{error}") debug(event, ) end |
#on_buffer_flushed_sync(event) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 83 def on_buffer_flushed_sync(event) = event[:messages] info(event, "Sync flushing of #{.size} messages from the buffer") debug(event, ) end |
#on_buffer_flushed_sync_error(event) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 91 def on_buffer_flushed_sync_error(event) = event[:dispatched] error = event[:error] error(event, "Sync flushing of #{.size} failed due to: #{error}") debug(event, ) end |
#on_message_buffered(event) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 50 def (event) = event[:message] info(event, "Buffering of a message to '#{[:topic]}' topic") debug(event, [, event[:producer]..size]) end |
#on_message_produced_async(event) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 16 def (event) = event[:message] info(event, "Async producing of a message to '#{[:topic]}' topic") debug(event, ) end |
#on_message_produced_sync(event) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 24 def (event) = event[:message] info(event, "Sync producing of a message to '#{[:topic]}' topic") debug(event, ) end |
#on_messages_buffered(event) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 58 def (event) = event[:messages] info(event, "Buffering of #{.size} messages") debug(event, [, event[:producer]..size]) end |
#on_messages_produced_async(event) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 32 def (event) = event[:messages] topics_count = .map { || "'#{[:topic]}'" }.uniq.count info(event, "Async producing of #{.size} messages to #{topics_count} topics") debug(event, ) end |
#on_messages_produced_sync(event) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 41 def (event) = event[:messages] topics_count = .map { || "'#{[:topic]}'" }.uniq.count info(event, "Sync producing of #{.size} messages to #{topics_count} topics") debug(event, ) end |
#on_producer_closed(event) ⇒ Object
100 101 102 103 |
# File 'lib/water_drop/instrumentation/stdout_listener.rb', line 100 def on_producer_closed(event) info event, 'Closing producer' debug event, event[:producer]..size end |