Class: Lapine::DTrace

Inherits:
Object
  • Object
show all
Defined in:
lib/lapine/dtrace.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDTrace

Returns a new instance of DTrace.


7
8
9
10
11
12
13
14
15
16
# File 'lib/lapine/dtrace.rb', line 7

def initialize
  @provider = USDT::Provider.create(:ruby, :lapine)

  @probes = {
    # args: Class name, payload
    dispatch_enter: provider.probe(:dispatch, :enter, :string, :string),
    # args: Class name, payload
    dispatch_return: provider.probe(:dispatch, :return, :string, :string),
  }
end

Instance Attribute Details

#probesObject (readonly)

Returns the value of attribute probes.


5
6
7
# File 'lib/lapine/dtrace.rb', line 5

def probes
  @probes
end

#providerObject (readonly)

Returns the value of attribute provider.


5
6
7
# File 'lib/lapine/dtrace.rb', line 5

def provider
  @provider
end

Class Method Details

.fire!(probe_name, *args) ⇒ Object

Raises:

  • (ArgumentError)

24
25
26
27
28
# File 'lib/lapine/dtrace.rb', line 24

def self.fire!(probe_name, *args)
  raise ArgumentError.new("Unknown probe: #{probe_name}") unless self.provider.probes[probe_name]
  probe = self.provider.probes[probe_name]
  probe.fire(*args) if probe.enabled?
end

.providerObject


18
19
20
21
22
# File 'lib/lapine/dtrace.rb', line 18

def self.provider
  @provider ||= new.tap do |p|
    p.provider.enable
  end
end