Sha256: 2305feed1a8b597c1a46d2cc675b51b8e38c022048db3a88bb9398b1b0284626

Contents?: true

Size: 1.35 KB

Versions: 6

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module WaterDrop
  module Instrumentation
    # Monitor is used to hookup external monitoring services to monitor how WaterDrop works
    # Since it is a pub-sub based on dry-monitor, you can use as many subscribers/loggers at the
    # same time, which means that you might have for example file logging and NewRelic at the same
    # time
    # @note This class acts as a singleton because we are only permitted to have single monitor
    #   per running process (just as logger)
    class Monitor < Dry::Monitor::Notifications
      # List of events that we support in the system and to which a monitor client can hook up
      # @note The non-error once support timestamp benchmarking
      EVENTS = %w[
        producer.closed
        message.produced_async
        message.produced_sync
        messages.produced_async
        messages.produced_sync
        message.buffered
        messages.buffered
        message.acknowledged
        buffer.flushed_async
        buffer.flushed_async.error
        buffer.flushed_sync
        buffer.flushed_sync.error
        statistics.emitted
      ].freeze

      private_constant :EVENTS

      # @return [WaterDrop::Instrumentation::Monitor] monitor instance for system instrumentation
      def initialize
        super(:waterdrop)
        EVENTS.each(&method(:register_event))
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
waterdrop-2.0.4 lib/water_drop/instrumentation/monitor.rb
waterdrop-2.0.3 lib/water_drop/instrumentation/monitor.rb
waterdrop-2.0.2 lib/water_drop/instrumentation/monitor.rb
waterdrop-2.0.1 lib/water_drop/instrumentation/monitor.rb
waterdrop-2.0.0 lib/water_drop/instrumentation/monitor.rb
waterdrop-2.0.0.rc1 lib/water_drop/instrumentation/monitor.rb