Sha256: 785e8ad5dac4327930ed2ce17a07a89caa16020ba569139aac4ca8c92c46ecf0

Contents?: true

Size: 715 Bytes

Versions: 4

Compression:

Stored size: 715 Bytes

Contents

# frozen_string_literal: true

module Mnemosyne
  class Probe
    # rubocop:disable Metrics/MethodLength
    def install
      setup

      self.class.subscriptions.each do |subscribe|
        ::ActiveSupport::Notifications.subscribe(subscribe) do |*args|
          trace = ::Mnemosyne::Instrumenter.current_trace
          next unless trace

          call(trace, *args)
        end
      end

      ::Mnemosyne::Instrumenter.logger.debug do
        "Installed probe #{self.class.name}"
      end
    end

    def setup
      # noop
    end

    class << self
      def subscriptions
        @subscriptions ||= Set.new
      end

      def subscribe(name)
        subscriptions << name
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mnemosyne-ruby-1.0.1 lib/mnemosyne/probe.rb
mnemosyne-ruby-1.0.0 lib/mnemosyne/probe.rb
mnemosyne-ruby-0.2.0 lib/mnemosyne/probe.rb
mnemosyne-ruby-0.1.0 lib/mnemosyne/probe.rb