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



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

def subscribe(name)
  subscriptions << name
end

.subscriptions ⇒ Object



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

def subscriptions
  @subscriptions ||= Set.new
end

Instance Method Details

#install ⇒ Object



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

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



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

def setup
  # noop
end