Sha256: ed20a2bba482dade19571929602d8528e72786d595195b6363a5af727955eccd

Contents?: true

Size: 699 Bytes

Versions: 19

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true

module Sbmt
  module KafkaConsumer
    module Instrumentation
      class ChainableMonitor < BaseMonitor
        attr_reader :monitors

        def initialize(monitors = [])
          super()

          @monitors = monitors
        end

        def instrument(event_id, payload = EMPTY_HASH, &block)
          return super if monitors.empty?

          chain = monitors.map { |monitor| monitor.new(event_id, payload) }
          traverse_chain = proc do
            if chain.empty?
              super
            else
              chain.shift.trace(&traverse_chain)
            end
          end
          traverse_chain.call
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
sbmt-kafka_consumer-3.3.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-3.2.2 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-3.2.1 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-3.2.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-3.1.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.8.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-3.0.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.7.1 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.7.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.6.1 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.6.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.5.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.4.1 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.4.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.3.1 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.3.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.2.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.1.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb
sbmt-kafka_consumer-2.0.0 lib/sbmt/kafka_consumer/instrumentation/chainable_monitor.rb