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: ProviderMissingError

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.



48
49
50
# File 'lib/ruby-static-tracing/provider.rb', line 48

def namespace
  @namespace
end

#tracepointsObject (readonly)

Returns the value of attribute tracepoints.



48
49
50
# File 'lib/ruby-static-tracing/provider.rb', line 48

def tracepoints
  @tracepoints
end

Class Method Details

.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 ProviderMissingError
  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?



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

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

#destroyObject

Completely removes the provider



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

def destroy; end

#disableObject

Disables the provider, unloading it from memory



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

def disable
  @enabled = !_disable_provider
end

#enableObject

Enable the provider, loading it into memory



61
62
63
# File 'lib/ruby-static-tracing/provider.rb', line 61

def enable
  @enabled = _enable_provider
end

#enabled?Boolean

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

Returns:

  • (Boolean)


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

def enabled?
  @enabled
end

#pathObject

Only supported on systems (linux) where backed by file



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

def path; end