Class: StaticTracing::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-static-tracing/provider.rb,
ext/ruby-static-tracing/darwin/ruby_static_tracing.c,
ext/ruby-static-tracing/linux/ruby_static_tracing.c

Overview

Provider is the wrapper around libstapsdt

Defined Under Namespace

Classes: ProviderNotFound

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/ruby-static-tracing/provider.rb', line 9

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



53
54
55
# File 'lib/ruby-static-tracing/provider.rb', line 53

def namespace
  @namespace
end

#tracepointsObject (readonly)

Returns the value of attribute tracepoints.



53
54
55
# File 'lib/ruby-static-tracing/provider.rb', line 53

def tracepoints
  @tracepoints
end

Class Method Details

.cleanObject



40
41
42
43
# File 'lib/ruby-static-tracing/provider.rb', line 40

def clean
  # FIXME: this should free first
  @providers = {}
end

.disable!Object

Forcefully disables all providers, unloading them from memory



36
37
38
# File 'lib/ruby-static-tracing/provider.rb', line 36

def disable!
  providers.values.each(&:disable)
end

.enable!Object

Enables each provider, ensuring it is loaded into memeory



30
31
32
# File 'lib/ruby-static-tracing/provider.rb', line 30

def enable!
  providers.values.each(&:enable)
end

.fetch(namespace) ⇒ Object

Gets a provider instance by name



22
23
24
25
26
# File 'lib/ruby-static-tracing/provider.rb', line 22

def fetch(namespace)
  providers.fetch(namespace) do
    raise ProviderNotFound
  end
end

.register(namespace) ⇒ Object

Gets a provider by name or creates one if not exists



17
18
19
# File 'lib/ruby-static-tracing/provider.rb', line 17

def register(namespace)
  providers[namespace] ||= new(namespace)
end

Instance Method Details

#add_tracepoint(tracepoint, *args) ⇒ Object

Adds a new tracepoint to this provider FIXME - should this be a dictionary, or are duplicate names allowed?



57
58
59
60
61
62
63
64
# File 'lib/ruby-static-tracing/provider.rb', line 57

def add_tracepoint(tracepoint, *args)
  if tracepoint.is_a?(String)
    tracepoint = Tracepoint.new(namespace, tracepoint, *args)
  elsif tracepoint.is_a?(Tracepoint)
    @tracepoints << tracepoint
  end
  tracepoint
end

#destroyObject



85
# File 'lib/ruby-static-tracing/provider.rb', line 85

def destroy; end

#disableObject

Disables the provider, unloading it from memory



72
73
74
# File 'lib/ruby-static-tracing/provider.rb', line 72

def disable
  @enabled = !_disable_provider
end

#enableObject

Enable the provider, loading it into memory



67
68
69
# File 'lib/ruby-static-tracing/provider.rb', line 67

def enable
  @enabled = _enable_provider
end

#enabled?Boolean

Returns true if the provider is enabled, meaning it is loaded into memory

Returns:

  • (Boolean)


78
79
80
# File 'lib/ruby-static-tracing/provider.rb', line 78

def enabled?
  @enabled
end

#pathObject

Only supported on systems (linux) where backed by file



83
# File 'lib/ruby-static-tracing/provider.rb', line 83

def path; end