Class: Honeybadger::Karafka::ErrorsListener

Inherits:
Object
  • Object
show all
Defined in:
lib/honeybadger/karafka.rb

Instance Method Summary collapse

Instance Method Details

#on_error_occurred(event) ⇒ Object

Sends error details to Honeybadger

Parameters:

  • event (Karafka::Core::Monitoring::Event)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/honeybadger/karafka.rb', line 9

def on_error_occurred(event)
  context = {
    type: event[:type]
  }
  tags = ["type:#{event[:type]}"]

  if (consumer = event.payload[:caller]).respond_to?(:messages)
    messages = consumer.messages
     = messages.
    consumer_group_id = consumer.topic.consumer_group.id

    context[:topic] = .topic
    context[:partition] = .partition
    context[:consumer_group] = consumer_group_id
  end

  Honeybadger.notify(event[:error], context: context)
end