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.
12 13 14 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 12 def initialize(logger) @logger = logger end |
Instance Method Details
#on_buffer_flushed_async(event) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 67 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
75 76 77 78 79 80 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 75 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
89 90 91 92 93 94 95 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 89 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
51 52 53 54 55 56 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 51 def (event) = event[:message] info(event, "Buffering of a message to '#{[:topic]}' topic") debug(event, []) end |
#on_message_produced_async(event) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 17 def (event) = event[:message] info(event, "Async producing of a message to '#{[:topic]}' topic") debug(event, ) end |
#on_message_produced_sync(event) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 25 def (event) = event[:message] info(event, "Sync producing of a message to '#{[:topic]}' topic") debug(event, ) end |
#on_messages_buffered(event) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 59 def (event) = event[:messages] info(event, "Buffering of #{.size} messages") debug(event, [, .size]) end |
#on_messages_produced_async(event) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 33 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
42 43 44 45 46 47 48 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 42 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
83 84 85 86 |
# File 'lib/waterdrop/instrumentation/logger_listener.rb', line 83 def on_producer_closed(event) info event, 'Closing producer' debug event, '' end |