Sha256: a98aa38aeb9139c835a3ac038fc7e75b8d1e970923a08e78251fdbe1dacbf93f

Contents?: true

Size: 1.05 KB

Versions: 22

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Sbmt
  module KafkaConsumer
    module Instrumentation
      module ListenerHelper
        delegate :logger, to: ::Sbmt::KafkaConsumer

        private

        def consumer_tags(event)
          message = event[:message]
          {
            topic: message.metadata.topic,
            partition: message.metadata.partition
          }
        end

        def inbox_tags(event)
          {
            inbox_name: event[:inbox_name],
            event_name: event[:event_name],
            status: event[:status]
          }
        end

        def error_message(error)
          if error.respond_to?(:message)
            error.message
          elsif error.respond_to?(:failure)
            error.failure
          else
            error.to_s
          end
        end

        def log_backtrace(error)
          if error.respond_to?(:backtrace)
            logger.error(error.backtrace.join("\n"))
          elsif error.respond_to?(:trace)
            logger.error(error.trace)
          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
sbmt-kafka_consumer-3.4.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-3.3.2 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-3.3.1 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-3.3.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-3.2.2 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-3.2.1 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-3.2.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-3.1.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-2.8.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-3.0.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-2.7.1 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-2.7.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-2.6.1 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-2.6.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-2.5.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-2.4.1 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-2.4.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-2.3.1 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-2.3.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb
sbmt-kafka_consumer-2.2.0 lib/sbmt/kafka_consumer/instrumentation/listener_helper.rb