Class: Tracker::KafkaTracker
- Defined in:
- lib/liquid/tracker/kafka_tracker.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #down? ⇒ Boolean
- #event(topic, data) ⇒ Object
-
#initialize(properties, dimensions = {}) ⇒ KafkaTracker
constructor
A new instance of KafkaTracker.
- #shutdown ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(properties, dimensions = {}) ⇒ KafkaTracker
Returns a new instance of KafkaTracker.
10 11 12 13 |
# File 'lib/liquid/tracker/kafka_tracker.rb', line 10 def initialize(properties, dimensions = {}) super(dimensions) @producer = Producer.new(ProducerConfig.new(properties)) end |
Instance Method Details
#down? ⇒ Boolean
15 16 17 18 19 |
# File 'lib/liquid/tracker/kafka_tracker.rb', line 15 def down? # TODO: async is fire and forget. we might want to handle # QueueFullExceptions later false end |
#event(topic, data) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/liquid/tracker/kafka_tracker.rb', line 21 def event(topic, data) @producer.send(KeyedMessage.new(topic, data)) rescue => e # TODO: maybe fall back to FileTracker here $log.exception(e, "failed to log #{topic}=#{data.inspect}") end |
#shutdown ⇒ Object
28 29 30 31 32 |
# File 'lib/liquid/tracker/kafka_tracker.rb', line 28 def shutdown @producer.close if @producer rescue Java::KafkaProducer::ProducerClosedException # pass end |