Sha256: c5eb1519577bd680b48c895395cf9ac2b04337c18b90bac2115d30a9a3520563

Contents?: true

Size: 1.02 KB

Versions: 17

Compression:

Stored size: 1.02 KB

Contents

require 'honeybadger/plugin'

module Honeybadger
  module Plugins
    Plugin.register :karafka do
      requirement { defined?(::Karafka) }

      execution do
        ::Karafka.monitor.subscribe('error.occurred') do |event|
          Honeybadger.notify(event[:error])
          Honeybadger.event('error.occurred', error: event[:error]) if config.load_plugin_insights?(:karafka)
        end

        if config.load_plugin_insights?(:karafka)
          ::Karafka.monitor.subscribe("consumer.consumed") do |event|
            context = {
              duration: event.payload[:time],
              consumer: event.payload[:caller].class.to_s,
              id: event.payload[:caller].id,
              topic: event.payload[:caller].messages.metadata.topic,
              messages_count: event.payload[:caller].messages.metadata.size,
              partition: event.payload[:caller].messages.metadata.partition
            }

            Honeybadger.event('consumer.consumed.karafka', context)
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
honeybadger-5.15.5 lib/honeybadger/plugins/karafka.rb
honeybadger-5.15.4 lib/honeybadger/plugins/karafka.rb
honeybadger-5.15.3 lib/honeybadger/plugins/karafka.rb
honeybadger-5.15.2 lib/honeybadger/plugins/karafka.rb
honeybadger-5.15.1 lib/honeybadger/plugins/karafka.rb
honeybadger-5.15.0 lib/honeybadger/plugins/karafka.rb
honeybadger-5.14.2 lib/honeybadger/plugins/karafka.rb
honeybadger-5.14.1 lib/honeybadger/plugins/karafka.rb
honeybadger-5.14.0 lib/honeybadger/plugins/karafka.rb
honeybadger-5.13.3 lib/honeybadger/plugins/karafka.rb
honeybadger-5.13.2 lib/honeybadger/plugins/karafka.rb
honeybadger-5.13.1 lib/honeybadger/plugins/karafka.rb
honeybadger-5.13.0 lib/honeybadger/plugins/karafka.rb
honeybadger-5.12.0 lib/honeybadger/plugins/karafka.rb
honeybadger-5.11.2 lib/honeybadger/plugins/karafka.rb
honeybadger-5.11.1 lib/honeybadger/plugins/karafka.rb
honeybadger-5.11.0 lib/honeybadger/plugins/karafka.rb