Class: Karafka::Monitor
- Inherits:
-
Object
- Object
- Karafka::Monitor
- Includes:
- Singleton
- Defined in:
- lib/karafka/monitor.rb
Overview
This class acts as a singleton because we are only permitted to have single monitor per running process (just as logger)
Monitor is used to hookup external monitoring services to monitor how Karafka works It provides a standarized API for checking incoming messages/enqueueing etc By default it implements logging functionalities but can be replaced with any more
sophisticated logging/monitoring system like Errbit, Airbrake, NewRelic
Keep in mind, that if you create your own monitor object, you will have to implement also logging functionality (or just inherit, super and do whatever you want)
Instance Method Summary collapse
-
#notice(caller_class, options = {}) ⇒ Object
This method is executed in many important places in the code (during data flow), like the moment before #perform_async, etc.
-
#notice_error(caller_class, e) ⇒ Object
This method is executed when we want to notify about an error that happened somewhere in the system.
Instance Method Details
#notice(caller_class, options = {}) ⇒ Object
We don’t provide a name of method in which this was called, because we can take it directly from Ruby (see #caller_label method of this class for more details)
This method is executed in many important places in the code (during data flow), like the moment before #perform_async, etc. For full list just grep for ‘monitor.notice’
24 25 26 |
# File 'lib/karafka/monitor.rb', line 24 def notice(caller_class, = {}) logger.info("#{caller_class}##{caller_label} with #{}") end |
#notice_error(caller_class, e) ⇒ Object
We don’t provide a name of method in which this was called, because we can take it directly from Ruby (see #caller_label method of this class for more details)
This method is executed when we want to notify about an error that happened somewhere in the system
36 37 38 39 40 41 42 43 44 |
# File 'lib/karafka/monitor.rb', line 36 def notice_error(caller_class, e) caller_exceptions_map.each do |level, types| next unless types.include?(caller_class) return logger.public_send(level, e) end logger.info(e) end |