Class: WaterDrop::Instrumentation::LoggerListener
- Inherits:
-
Object
- Object
- WaterDrop::Instrumentation::LoggerListener
- Defined in:
- lib/waterdrop/instrumentation/logger_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) ⇒ LoggerListener
constructor
A new instance of LoggerListener.
- #on_buffer_flushed_async(event) ⇒ Object
- #on_buffer_flushed_sync(event) ⇒ Object
- #on_error_occurred(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) ⇒ LoggerListener
Returns a new instance of LoggerListener.
11 12 13 |
# File 'lib/waterdrop/instrumentation/logger_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/waterdrop/instrumentation/logger_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_sync(event) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 74 def on_buffer_flushed_sync(event) = event[:messages] info(event, "Sync flushing of #{.size} messages from the buffer") debug(event, ) end |
#on_error_occurred(event) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 88 def on_error_occurred(event) error = event[:error] type = event[:type] error(event, "Error occurred: #{error} - #{type}") debug(event, '') end |
#on_message_buffered(event) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 50 def (event) = event[:message] info(event, "Buffering of a message to '#{[:topic]}' topic") debug(event, []) end |
#on_message_produced_async(event) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/waterdrop/instrumentation/logger_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/waterdrop/instrumentation/logger_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/waterdrop/instrumentation/logger_listener.rb', line 58 def (event) = event[:messages] info(event, "Buffering of #{.size} messages") debug(event, [, .size]) end |
#on_messages_produced_async(event) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/waterdrop/instrumentation/logger_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/waterdrop/instrumentation/logger_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
82 83 84 85 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 82 def on_producer_closed(event) info event, 'Closing producer' debug event, '' end |