Class: Cache::Object::DTraceProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/cache/object/dtrace_provider.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDTraceProvider

Returns a new instance of DTraceProvider.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cache/object/dtrace_provider.rb', line 8

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

  @probes = {
    # args: Class name, id, ttl
    fetch: provider.probe(:adapter, :fetch, :string, :string, :string),
    # args: Class name, id, ttl
    fetch_miss: provider.probe(:adapter, :fetch_miss, :string, :string, :string),
    # args: Class name, attributes.inspect, ttl
    fetch_mapping: provider.probe(:adapter, :fetch_mapping, :string, :string, :string),
    # args: Class name, attributes.inspect, ttl
    fetch_mapping_miss: provider.probe(:adapter, :fetch_mapping_miss, :string, :string, :string),
    # args: args.inspect, hits, misses
    read_multi: provider.probe(:adapter, :read_multi, :string, :integer, :integer),
    # args: class_name, id, ttl
    write: provider.probe(:adapter, :write, :string, :string, :string),
    # args: class_name, id
    delete: provider.probe(:adapter, :delete, :string, :string)
  }
end

Instance Attribute Details

#probesObject (readonly)

Returns the value of attribute probes.



6
7
8
# File 'lib/cache/object/dtrace_provider.rb', line 6

def probes
  @probes
end

#providerObject (readonly)

Returns the value of attribute provider.



6
7
8
# File 'lib/cache/object/dtrace_provider.rb', line 6

def provider
  @provider
end

Class Method Details

.fire!(probe_name, *args) ⇒ Object



35
36
37
38
39
# File 'lib/cache/object/dtrace_provider.rb', line 35

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

.providerObject



29
30
31
32
33
# File 'lib/cache/object/dtrace_provider.rb', line 29

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