Sha256: 44fe87c57033d295ae9b50ffecf1e15f96c32b795330ce3b81563eea98f8bf5f

Contents?: true

Size: 1.41 KB

Versions: 27

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module WaterDrop
  module Instrumentation
    module Callbacks
      # Callback that kicks in when error occurs and is published in a background thread
      class Error
        # @param producer_id [String] id of the current producer
        # @param client_name [String] rdkafka client name
        # @param monitor [WaterDrop::Instrumentation::Monitor] monitor we are using
        def initialize(producer_id, client_name, monitor)
          @producer_id = producer_id
          @client_name = client_name
          @monitor = monitor
        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 producer
        # @note When there is a particular message produce error (not internal error), the error
        #   is shipped via the delivery callback, not via error callback.
        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

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

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
waterdrop-2.7.0.rc2 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.7.0.rc1 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.7.0.beta2 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.7.0.beta1 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.7.0.alpha3 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.7.0.alpha2 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.7.0.alpha1 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.14 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.13 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.12 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.11 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.10 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.9 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.8 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.7 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.6 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.5 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.4 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.3 lib/waterdrop/instrumentation/callbacks/error.rb
waterdrop-2.6.2 lib/waterdrop/instrumentation/callbacks/error.rb