Sha256: 8a465edb8df302f78449a98a3b0bbb2d4f7a5ed56f2c5cf6310291984b429537

Contents?: true

Size: 1.46 KB

Versions: 51

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

module Karafka
  module Instrumentation
    # Callbacks used to transport things from rdkafka
    module Callbacks
      # Callback that kicks in when consumer error occurs and is published in a background thread
      class Error
        # @param subscription_group_id [String] id of the current subscription group instance
        # @param consumer_group_id [String] id of the current consumer group
        # @param client_name [String] rdkafka client name
        def initialize(subscription_group_id, consumer_group_id, client_name)
          @subscription_group_id = subscription_group_id
          @consumer_group_id = consumer_group_id
          @client_name = client_name
        end

        # Runs the instrumentation monitor with error
        # @param client_name [String] rdkafka client name
        # @param error [Rdkafka::Error] error that occurred
        # @note It will only instrument on errors of the client of our consumer
        def call(client_name, error)
          # Emit only errors related to our client
          # Same as with statistics (mor explanation there)
          return unless @client_name == client_name

          ::Karafka.monitor.instrument(
            'error.occurred',
            caller: self,
            subscription_group_id: @subscription_group_id,
            consumer_group_id: @consumer_group_id,
            type: 'librdkafka.error',
            error: error
          )
        end
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
karafka-2.4.0.rc1 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.3.4 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.4.0.beta2 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.4.0.beta1 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.3.3 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.3.2 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.3.1 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.3.0 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.3.0.rc1 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.3.0.alpha2 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.3.0.alpha1 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.2.14 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.2.13 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.2.12 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.2.11 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.2.10 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.2.9 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.2.8 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.2.8.beta1 lib/karafka/instrumentation/callbacks/error.rb
karafka-2.2.7 lib/karafka/instrumentation/callbacks/error.rb