class StaticTracing::Provider

A wrapper for a USDT tracepoint provider This corresponds to a namespace of tracepoints By convention, we will often create one per class or module.

Attributes

name[RW]
namespace[R]
tracepoints[R]

Public Class Methods

disable!() click to toggle source

Forcefully disables all providers, unloading them from memory

# File lib/ruby-static-tracing/provider.rb, line 35
def disable!
  providers.values.each(&:disable)
end
enable!() click to toggle source

Enables each provider, ensuring it is loaded into memeory

# File lib/ruby-static-tracing/provider.rb, line 29
def enable!
  providers.values.each(&:enable)
end
fetch(namespace) click to toggle source

Gets a provider instance by name

# File lib/ruby-static-tracing/provider.rb, line 21
def fetch(namespace)
  providers.fetch(namespace) do
    raise ProviderMissingError
  end
end
new(namespace) click to toggle source

ALWAYS use register, never call .new dilectly

# File lib/ruby-static-tracing/provider.rb, line 84
def initialize(namespace)
  if StaticTracing::Platform.supported_platform?
    provider_initialize(namespace)
    @enabled = false
  else
    StaticTracing.issue_disabled_tracepoints_warning
  end
  @namespace = namespace
  @tracepoints = {}
end
register(namespace) click to toggle source

Gets a provider by name or creates one if not exists

# File lib/ruby-static-tracing/provider.rb, line 16
def register(namespace)
  providers[namespace] ||= new(namespace)
end

Public Instance Methods

add_tracepoint(tracepoint, *args) click to toggle source

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

# File lib/ruby-static-tracing/provider.rb, line 51
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
destroy() click to toggle source

Completely removes the provider

# File lib/ruby-static-tracing/provider.rb, line 79
def destroy; end
disable() click to toggle source

Disables the provider, unloading it from memory

# File lib/ruby-static-tracing/provider.rb, line 65
def disable
  @enabled = !_disable_provider
end
enable() click to toggle source

Enable the provider, loading it into memory

# File lib/ruby-static-tracing/provider.rb, line 60
def enable
  @enabled = _enable_provider
end
enabled?() click to toggle source

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

# File lib/ruby-static-tracing/provider.rb, line 71
def enabled?
  @enabled
end
path() click to toggle source

Only supported on systems (linux) where backed by file

# File lib/ruby-static-tracing/provider.rb, line 76
def path; end