Class: Mnemosyne::Probe

Inherits:
Object
  • Object
show all
Defined in:
lib/mnemosyne/probe.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.subscribe(name) ⇒ Object



32
33
34
# File 'lib/mnemosyne/probe.rb', line 32

def subscribe(name)
  subscriptions << name
end

.subscriptions ⇒ Object



28
29
30
# File 'lib/mnemosyne/probe.rb', line 28

def subscriptions
  @subscriptions ||= Set.new
end

Instance Method Details

#install ⇒ Object

rubocop:disable Metrics/MethodLength



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mnemosyne/probe.rb', line 6

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

#setup ⇒ Object



23
24
25
# File 'lib/mnemosyne/probe.rb', line 23

def setup
  # noop
end